diff --git a/.gitattributes b/.gitattributes index 852eec4d6386dec5387dcc9a9190f48ebb5e576b..9d638481a8470b033193906e495e763478186966 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,7 @@ pcre/testdata/greppatN4 -text *.MYD binary *.MYI binary *.class binary +*.jar binary *.c diff=cpp *.h diff=cpp diff --git a/.gitignore b/.gitignore index c3c140bb99ab9d01f4fd1172c4799454160b227c..acbb8d21372d5146fca25106464e3518369b0cab 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ scripts/mytop scripts/wsrep_sst_common scripts/wsrep_sst_mysqldump scripts/wsrep_sst_rsync +scripts/wsrep_sst_rsync_wan scripts/wsrep_sst_mariabackup scripts/wsrep_sst_xtrabackup scripts/wsrep_sst_xtrabackup-v2 @@ -477,3 +478,9 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ + +# macOS garbage +.DS_Store + +# QtCreator && CodeBlocks +*.cbp diff --git a/CMakeLists.txt b/CMakeLists.txt index b4de70a283d94a2aa6edea6c5ff6e8247a027d56..fa1ed701a812de4c6cc59ddd10e5f071de377b56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ INCLUDE(plugin) INCLUDE(install_macros) INCLUDE(systemd) INCLUDE(mysql_add_executable) +INCLUDE(compile_flags) # Handle options OPTION(DISABLE_SHARED @@ -361,6 +362,10 @@ INCLUDE(maintainer) IF(WITH_UNIT_TESTS) ENABLE_TESTING() + # This is the only instance where ADD_TEST should be used, + # to make sure that make test will run MTR, + # use MY_ADD_TEST macro to add other tests + ADD_TEST(NAME MTR COMMAND ./mysql-test-run WORKING_DIRECTORY "mysql-test") ADD_SUBDIRECTORY(unittest/mytap) ADD_SUBDIRECTORY(unittest/strings) ADD_SUBDIRECTORY(unittest/examples) diff --git a/CREDITS b/CREDITS index 7572f6f5dd92ed21b2bb850e19438463a4203dc2..1788b6304fe7b995ac6e0f4d5fc2f92ffd832e13 100644 --- a/CREDITS +++ b/CREDITS @@ -5,15 +5,14 @@ The current main sponsors of the MariaDB Foundation are: Alibaba Cloud https://www.alibabacloud.com/ (2017) Booking.com https://www.booking.com (2013) +MariaDB Corporation https://www.mariadb.com (2013) Microsoft https://microsoft.com/ (2017) Tencent Cloud https://cloud.tencent.com (2017) Development Bank of Singapore https://dbs.com (2016) IBM https://www.ibm.com (2017) -MariaDB Corporation https://www.mariadb.com (2013) Visma https://visma.com (2015) Acronis http://acronis.com (2016) Nexedi https://www.nexedi.com (2016) -Automattic https://automattic.com (2014) Tencent Game DBA http://tencentdba.com/about (2016) Tencent TDSQL http://tdsql.org (2016) Verkkokauppa.com https://www.verkkokauppa.com (2015) diff --git a/Docs/INFO_SRC b/Docs/INFO_SRC index bd70a3ac3c386014982a94db825349833320190e..707e56e9e8e5fcde0975080e0648c80d41d6fc77 100644 --- a/Docs/INFO_SRC +++ b/Docs/INFO_SRC @@ -1,8 +1,8 @@ -commit: aba15b864af664276261dcbbdaef35268d407af1 -date: 2018-02-04 04:28:14 +0200 -build-date: 2018-02-04 02:30:32 +0000 -short: aba15b8 +commit: 9f848da640dd6c3f44d56eae18204370ae7f835c +date: 2018-06-16 01:20:44 +0200 +build-date: 2018-06-16 00:19:48 +0000 +short: 9f848da branch: HEAD -MariaDB source 10.1.31 +MariaDB source 10.1.34 diff --git a/VERSION b/VERSION index 244d28b6ba5970687c1fae7514bcbb8b468aeeb2..f9ccf7c618851825919daed1aa05e57969e78f99 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=31 +MYSQL_VERSION_PATCH=34 diff --git a/client/mysql.cc b/client/mysql.cc index 7973c3c7fc39a50f528e64a22083cac7391f081a..2cbb6ae25ddbf9450ce45e828a4f9321f874adb9 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1175,11 +1175,7 @@ int main(int argc,char *argv[]) close(stdout_fileno_copy); /* Clean up dup(). */ } - if (load_defaults("my",load_default_groups,&argc,&argv)) - { - my_end(0); - exit(1); - } + load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv=argv; if ((status.exit_status= get_options(argc, (char **) argv))) mysql_end(-1); @@ -1229,15 +1225,17 @@ int main(int argc,char *argv[]) window_resize(0); #endif - put_info("Welcome to the MariaDB monitor. Commands end with ; or \\g.", - INFO_INFO); - my_snprintf((char*) glob_buffer.ptr(), glob_buffer.alloced_length(), - "Your %s connection id is %lu\nServer version: %s\n", - mysql_get_server_name(&mysql), - mysql_thread_id(&mysql), server_version_string(&mysql)); - put_info((char*) glob_buffer.ptr(),INFO_INFO); - - put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"), INFO_INFO); + if (!status.batch) + { + put_info("Welcome to the MariaDB monitor. Commands end with ; or \\g.", + INFO_INFO); + my_snprintf((char*) glob_buffer.ptr(), glob_buffer.alloced_length(), + "Your %s connection id is %lu\nServer version: %s\n", + mysql_get_server_name(&mysql), + mysql_thread_id(&mysql), server_version_string(&mysql)); + put_info((char*) glob_buffer.ptr(),INFO_INFO); + put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"), INFO_INFO); + } #ifdef HAVE_READLINE initialize_readline((char*) my_progname); diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cbdd398c1e1cb72189c3c859c9b6470b713b6a16..5eb495774cef128c2f96fc2ad1605ed013a7eb83 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1133,6 +1133,8 @@ int main(int argc, char **argv) char self_name[FN_REFLEN + 1]; MY_INIT(argv[0]); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); + defaults_argv= argv; /* Must be freed by 'free_defaults' */ #if __WIN__ if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0) @@ -1145,10 +1147,6 @@ int main(int argc, char **argv) init_dynamic_string(&conn_args, "", 512, 256)) die("Out of memory"); - if (load_defaults("my", load_default_groups, &argc, &argv)) - die(NULL); - defaults_argv= argv; /* Must be freed by 'free_defaults' */ - if (handle_options(&argc, &argv, my_long_options, get_one_option)) die(NULL); if (debug_info_flag) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 897c2eb41c338d86303dba6bcf7323a2d9dfceb7..d4d40b0a0f28fc4b5429e0cec243468ca8d2a111 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -319,8 +319,7 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); mysql_init(&mysql); sf_leaking_memory=1; /* don't report memory leaks on early exits */ - if ((error= load_defaults("my",load_default_groups,&argc,&argv))) - goto err1; + load_defaults_or_exit("my", load_default_groups, &argc, &argv); save_argv = argv; /* Save for free_defaults */ if ((error=handle_options(&argc, &argv, my_long_options, get_one_option))) @@ -500,10 +499,8 @@ int main(int argc,char *argv[]) my_free(shared_memory_base_name); #endif free_defaults(save_argv); -err1: my_end(my_end_arg); - exit(error); - return 0; + return error; } diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index b871a70ef01e215a48233c7ac86bb5e5e117cdce..9753125dd67188f887c1d62ca5253da8adfda6e8 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2666,9 +2666,7 @@ int main(int argc, char** argv) tzset(); // set tzname init_alloc_root(&s_mem_root, 16384, 0, MYF(0)); - if (load_defaults("my", load_groups, &argc, &argv)) - exit(1); - + load_defaults_or_exit("my", load_groups, &argc, &argv); defaults_argv= argv; if (!(binlog_filter= new Rpl_filter)) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 47cb38751eb53f823f7028e3a4444ab532bac3fc..a4410eba8aa9b67d227ccfb728790c66377e7e80 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1165,9 +1165,7 @@ int main(int argc, char **argv) /* ** Check out the args */ - if (load_defaults("my", load_default_groups, &argc, &argv)) - goto end2; - + load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv= argv; if (get_options(&argc, &argv)) goto end1; @@ -1243,7 +1241,6 @@ int main(int argc, char **argv) my_free(shared_memory_base_name); mysql_library_end(); free_defaults(defaults_argv); - end2: my_end(my_end_arg); return ret; } /* main */ diff --git a/client/mysqldump.c b/client/mysqldump.c index 5c0ec2a551006906d3408aa606e615bf9b90acfe..f67e52c1b127ec20cf4ba1a071e3afc19076a306 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -976,8 +976,7 @@ static int get_options(int *argc, char ***argv) opt_net_buffer_length= *mysql_params->p_net_buffer_length; md_result_file= stdout; - if (load_defaults("my",load_default_groups,argc,argv)) - return 1; + load_defaults_or_exit("my", load_default_groups, argc, argv); defaults_argv= *argv; if (my_hash_init(&ignore_table, charset_info, 16, 0, 0, @@ -4995,6 +4994,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (opt_xml) print_xml_tag(md_result_file, "", "\n", "database", "name=", db, NullS); + + /* obtain dump of routines (procs/functions) */ + if (opt_routines && mysql_get_server_version(mysql) >= 50009) + { + DBUG_PRINT("info", ("Dumping routines for database %s", db)); + dump_routines_for_db(db); + } + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) { verbose_msg("-- Setting savepoint...\n"); @@ -5004,7 +5011,6 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_RETURN(1); } } - /* Dump each selected table */ for (pos= dump_tables; pos < end; pos++) { @@ -5066,12 +5072,6 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_PRINT("info", ("Dumping events for database %s", db)); dump_events_for_db(db); } - /* obtain dump of routines (procs/functions) */ - if (opt_routines && mysql_get_server_version(mysql) >= 50009) - { - DBUG_PRINT("info", ("Dumping routines for database %s", db)); - dump_routines_for_db(db); - } free_root(&glob_root, MYF(0)); if (opt_xml) { diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 9c84d4a62a6b4fc3b73e11a8ceff648304f05d84..a9c24e20b0a196e2559fb86dcfdd63d9c47ff368 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -641,8 +641,7 @@ int main(int argc, char **argv) MY_INIT(argv[0]); sf_leaking_memory=1; /* don't report memory leaks on early exits */ - if (load_defaults("my",load_default_groups,&argc,&argv)) - return 1; + load_defaults_or_exit("my", load_default_groups, &argc, &argv); /* argv is changed in the program */ argv_to_free= argv; if (get_options(&argc, &argv)) diff --git a/client/mysqlshow.c b/client/mysqlshow.c index f851c15106e8010b64abc572b15016e543b90d0a..95ee8d697f3d1e51d988653067b2be5a3ac2ffd1 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -71,8 +71,7 @@ int main(int argc, char **argv) static char **defaults_argv; MY_INIT(argv[0]); sf_leaking_memory=1; /* don't report memory leaks on early exits */ - if (load_defaults("my",load_default_groups,&argc,&argv)) - exit(1); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv=argv; get_options(&argc,&argv); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 6a0b214305c7961e469ab342ac69a5aebcf19bc0..fd30776446d77b3da0c5380ca32d02c52cde9a33 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -325,11 +325,7 @@ int main(int argc, char **argv) MY_INIT(argv[0]); sf_leaking_memory=1; /* don't report memory leaks on early exits */ - if (load_defaults("my",load_default_groups,&argc,&argv)) - { - my_end(0); - exit(1); - } + load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv=argv; if (get_options(&argc,&argv)) { @@ -857,7 +853,7 @@ build_table_string(void) if (auto_generate_sql_guid_primary) { - dynstr_append(&table_string, "id varchar(32) primary key"); + dynstr_append(&table_string, "id varchar(36) primary key"); if (num_int_cols || num_char_cols || auto_generate_sql_guid_primary) dynstr_append(&table_string, ","); @@ -872,7 +868,7 @@ build_table_string(void) if (count) /* Except for the first pass we add a comma */ dynstr_append(&table_string, ","); - if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(32) unique key", count) + if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(36) unique key", count) > HUGE_STRING_LENGTH) { fprintf(stderr, "Memory Allocation error in create table\n"); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 844a2d7bbf8daf8fef925dd390a9de85c7ed8c66..a58b83bd372ca3a3f025acee548c3e219e647c6e 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -520,7 +520,7 @@ struct st_match_err struct st_expected_errors { - struct st_match_err err[10]; + struct st_match_err err[12]; uint count; }; static struct st_expected_errors saved_expected_errors; @@ -903,6 +903,8 @@ pthread_handler_t connection_thread(void *arg) end_thread: cn->query_done= 1; + mysql_close(cn->mysql); + cn->mysql= 0; mysql_thread_end(); pthread_exit(0); return 0; @@ -1418,7 +1420,7 @@ void close_statements() for (con= connections; con < next_con; con++) { if (con->stmt) - mysql_stmt_close(con->stmt); + do_stmt_close(con); con->stmt= 0; } DBUG_VOID_RETURN; @@ -2678,7 +2680,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end) init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); do_eval(&ds_query, query, end, FALSE); - if (mysql_real_query(mysql, ds_query.str, ds_query.length)) + if (mysql_real_query(mysql, ds_query.str, ds_query.length) || !(res= mysql_store_result(mysql))) { handle_error(curr_command, mysql_errno(mysql), mysql_error(mysql), mysql_sqlstate(mysql), &ds_res); @@ -2688,13 +2690,6 @@ void var_query_set(VAR *var, const char *query, const char** query_end) DBUG_VOID_RETURN; } - if (!(res= mysql_store_result(mysql))) - { - report_or_die("Query '%s' didn't return a result set", ds_query.str); - dynstr_free(&ds_query); - eval_expr(var, "", 0); - DBUG_VOID_RETURN; - } dynstr_free(&ds_query); if ((row= mysql_fetch_row(res)) && row[0]) @@ -7306,9 +7301,7 @@ get_one_option(int optid, const struct my_option *opt, char *argument) int parse_args(int argc, char **argv) { - if (load_defaults("my",load_default_groups,&argc,&argv)) - exit(1); - + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; if ((handle_options(&argc, &argv, my_long_options, get_one_option))) @@ -8746,6 +8739,7 @@ void init_re(void) "[[:space:]]*SELECT[[:space:]]|" "[[:space:]]*CREATE[[:space:]]+TABLE[[:space:]]|" "[[:space:]]*DO[[:space:]]|" + "[[:space:]]*HANDLER[[:space:]]+.*[[:space:]]+READ[[:space:]]|" "[[:space:]]*SET[[:space:]]+OPTION[[:space:]]|" "[[:space:]]*DELETE[[:space:]]+MULTI[[:space:]]|" "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|" diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake index ef675959059c4de63019e5eac74e388942972558..673361ab8fe1398797ccc7332744d414a729f40b 100644 --- a/cmake/check_compiler_flag.cmake +++ b/cmake/check_compiler_flag.cmake @@ -32,25 +32,25 @@ MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") ENDMACRO() -FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag) +FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag_to_set) # At the moment this is gcc-only. # Let's avoid expensive compiler tests on Windows: IF(WIN32) RETURN() ENDIF() - MY_CHECK_C_COMPILER_FLAG(${flag}) - MY_CHECK_CXX_COMPILER_FLAG(${flag}) - STRING(REGEX REPLACE "[-,= +]" "_" result "${flag}") + STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) + MY_CHECK_C_COMPILER_FLAG(${flag_to_check}) + MY_CHECK_CXX_COMPILER_FLAG(${flag_to_check}) + STRING(REGEX REPLACE "[-,= +]" "_" result "${flag_to_check}") FOREACH(lang C CXX) IF (HAVE_${lang}_${result}) IF(ARGN) FOREACH(type ${ARGN}) - SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE) + SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE) ENDFOREACH() ELSE() - SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag}" PARENT_SCOPE) + SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag_to_set}" PARENT_SCOPE) ENDIF() ENDIF() ENDFOREACH() ENDFUNCTION() - diff --git a/cmake/ctest.cmake b/cmake/ctest.cmake index 08852a366f6d46b1a4696ec3c92f0e555d3c0e00..fde7e1632f6c15356cd0e69e165f3faa76107b7b 100644 --- a/cmake/ctest.cmake +++ b/cmake/ctest.cmake @@ -2,7 +2,7 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) MACRO(MY_ADD_TEST name) - ADD_TEST(${name} ${name}-t) + ADD_TEST(NAME ${name} COMMAND ${name}-t CONFIGURATIONS default_ignore) ENDMACRO() MACRO (MY_ADD_TESTS) diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 0541cca86a5d810778961741b63fcea6ccd3520e..4e902d7fed8c59c683b50ce47ff7d079507f87b4 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -14,54 +14,32 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Common warning flags for GCC, G++, Clang and Clang++ -SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self") -MY_CHECK_C_COMPILER_FLAG("-Wvla") # Requires GCC 4.3+ or Clang -IF(HAVE_C__Wvla) - SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") -ENDIF() - -MY_CHECK_C_COMPILER_FLAG("-Wno-format-truncation") -IF(HAVE_C__Wno_format_truncation) - SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wno-format-truncation") -ENDIF() - -# Common warning flags for GCC and Clang -SET(MY_C_WARNING_FLAGS - "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") - -# Common warning flags for G++ and Clang++ -SET(MY_CXX_WARNING_FLAGS - "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter") - -# Extra warning flags for Clang++ -IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - SET(MY_CXX_WARNING_FLAGS - "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field") -ENDIF() - -# Turn on Werror (warning => error) when using maintainer mode. -IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") - SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") - SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") -ENDIF() - -# Set warning flags for GCC/Clang -IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}") -ENDIF() -# Set warning flags for G++/Clang++ -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}") -ENDIF() +SET(MY_WARNING_FLAGS + -Wall + -Wdeclaration-after-statement + -Wextra + -Wformat-security + -Wno-format-truncation + -Wno-init-self + -Wno-nonnull-compare + -Wno-null-conversion + -Wno-unused-parameter + -Wno-unused-private-field + -Woverloaded-virtual + -Wvla + -Wwrite-strings + ) IF(MYSQL_MAINTAINER_MODE MATCHES "ON") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") + SET(WHERE) ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}") + SET(WHERE DEBUG) ENDIF() +FOREACH(F ${MY_WARNING_FLAGS}) + MY_CHECK_AND_SET_COMPILER_FLAG(${F} ${WHERE}) +ENDFOREACH() + IF(CMAKE_C_COMPILER_ID MATCHES "GNU") STRING(REPLACE " -E " " -E -dDI " CMAKE_C_CREATE_PREPROCESSED_SOURCE ${CMAKE_C_CREATE_PREPROCESSED_SOURCE}) ENDIF() diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index b5dc8b9f1573127e81537010be1fc4216f53a416..9fa127380a43a878421f0b10e57e2c0e80b97057 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "21") +SET(WSREP_PATCH_VERSION "23") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION diff --git a/configure.cmake b/configure.cmake index a1cddbb37fa69a3cca14e5e7f38da45d9c941210..df180e72963712c57fa3b31223d64c336de11328 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1111,6 +1111,9 @@ CHECK_INCLUDE_FILE(ucontext.h HAVE_UCONTEXT_H) IF(NOT HAVE_UCONTEXT_H) CHECK_INCLUDE_FILE(sys/ucontext.h HAVE_UCONTEXT_H) ENDIF() +IF(HAVE_UCONTEXT_H) + CHECK_FUNCTION_EXISTS(makecontext HAVE_UCONTEXT_H) +ENDIF() CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec "time.h" STRUCT_TIMESPEC_HAS_TV_SEC) CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_nsec "time.h" STRUCT_TIMESPEC_HAS_TV_NSEC) diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index ac15460660cfe8188e988edb24156a7811569f71..aa05b36153f5a3ba2f4e600ce96d3c7f6dd33b38 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -52,7 +52,7 @@ ELSE() SET(NT_SERVICE_SOURCE) ENDIF() -ADD_DEFINITIONS(-DPCRE_STATIC=1) +ADD_DEFINITIONS(-DPCRE_STATIC=1 -DHAVE_OPENSSL=1) MYSQL_ADD_EXECUTABLE(mariabackup xtrabackup.cc @@ -61,7 +61,7 @@ MYSQL_ADD_EXECUTABLE(mariabackup datasink.c ds_buffer.c ds_compress.c - ds_local.c + ds_local.cc ds_stdout.c ds_tmpfile.c ds_xbstream.c @@ -98,7 +98,7 @@ ENDIF() ######################################################################## MYSQL_ADD_EXECUTABLE(mbstream ds_buffer.c - ds_local.c + ds_local.cc ds_stdout.c datasink.c xbstream.c @@ -112,6 +112,7 @@ TARGET_LINK_LIBRARIES(mbstream mysys crc ) +ADD_DEPENDENCIES(mbstream GenError) IF(MSVC) SET_TARGET_PROPERTIES(mbstream PROPERTIES LINK_FLAGS setargv.obj) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index c019209faad5ba915cd008a8193409ebc850520a..d3253348d72c7f34008c8692e07869a8d814e2c0 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -975,6 +975,9 @@ copy_file(ds_ctxt_t *datasink, datafile_cur_t cursor; xb_fil_cur_result_t res; const char *action; + const char *dst_path = + (xtrabackup_copy_back || xtrabackup_move_back)? + dst_file_path : trim_dotslash(dst_file_path); if (!datafile_open(src_file_path, &cursor, thread_n)) { goto error_close; @@ -982,8 +985,7 @@ copy_file(ds_ctxt_t *datasink, strncpy(dst_name, cursor.rel_path, sizeof(dst_name)); - dstfile = ds_open(datasink, trim_dotslash(dst_file_path), - &cursor.statinfo); + dstfile = ds_open(datasink, dst_path, &cursor.statinfo); if (dstfile == NULL) { msg("[%02u] error: " "cannot open the destination stream for %s\n", diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 6f425e9419f818a10c9bbc5683868ccc1351609d..7f0ad8a8361bf92e10b9579e106cb97ba49a67c4 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -91,7 +91,7 @@ time_t history_lock_time; MYSQL *mysql_connection; -my_bool opt_ssl_verify_server_cert; +extern my_bool opt_ssl_verify_server_cert, opt_use_ssl; MYSQL * xb_mysql_connect() @@ -477,7 +477,7 @@ get_mysql_vars(MYSQL *connection) innodb_data_file_path_var, MYF(MY_FAE)); } - if (innodb_data_home_dir_var && *innodb_data_home_dir_var) { + if (innodb_data_home_dir_var) { innobase_data_home_dir = my_strdup( innodb_data_home_dir_var, MYF(MY_FAE)); } @@ -1521,6 +1521,44 @@ write_xtrabackup_info(MYSQL *connection) extern const char *innodb_checksum_algorithm_names[]; +#ifdef _WIN32 +#include +#endif + +static std::string make_local_paths(const char *data_file_path) +{ + if (strchr(data_file_path, '/') == 0 +#ifdef _WIN32 + && strchr(data_file_path, '\\') == 0 +#endif + ){ + return std::string(data_file_path); + } + + std::ostringstream buf; + + char *dup = strdup(innobase_data_file_path); + ut_a(dup); + char *p; + char * token = strtok_r(dup, ";", &p); + while (token) { + if (buf.tellp()) + buf << ";"; + + char *fname = strrchr(token, '/'); +#ifdef _WIN32 + fname = std::max(fname,strrchr(token, '\\')); +#endif + if (fname) + buf << fname + 1; + else + buf << token; + token = strtok_r(NULL, ";", &p); + } + free(dup); + return buf.str(); +} + bool write_backup_config_file() { int rc= backup_file_printf("backup-my.cnf", @@ -1541,7 +1579,7 @@ bool write_backup_config_file() "%s\n", innodb_checksum_algorithm_names[srv_checksum_algorithm], innodb_checksum_algorithm_names[srv_log_checksum_algorithm], - innobase_data_file_path, + make_local_paths(innobase_data_file_path).c_str(), srv_n_log_files, innobase_log_file_size, srv_page_size, diff --git a/extra/mariabackup/common.h b/extra/mariabackup/common.h index 7b1dfd7a0dbed198b02b55dbff49d714d7219cad..340ad66e28a0ef617688a8132a31959514ceab6c 100644 --- a/extra/mariabackup/common.h +++ b/extra/mariabackup/common.h @@ -27,7 +27,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include -# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open) +/** Determine if (i) is a user tablespace id or not. */ +# define fil_is_user_tablespace_id(i) (i != 0 \ + && !srv_is_undo_tablespace(i)) #ifdef _MSC_VER #define stat _stati64 diff --git a/extra/mariabackup/datasink.c b/extra/mariabackup/datasink.c index 460e0e8ca1947f3d8e975314a7f3f8a0ea2df23b..1459da2fb57b0ee4dbc1f0be03406716e7c157ca 100644 --- a/extra/mariabackup/datasink.c +++ b/extra/mariabackup/datasink.c @@ -108,7 +108,7 @@ Write to a datasink file. int ds_write(ds_file_t *file, const void *buf, size_t len) { - return file->datasink->write(file, buf, len); + return file->datasink->write(file, (const uchar *)buf, len); } /************************************************************************ diff --git a/extra/mariabackup/datasink.h b/extra/mariabackup/datasink.h index 8bf1321aad17dccb386d2ca3ca044faf9584a313..5962e9ba4b75597901a976df7561cf0b4aea44a1 100644 --- a/extra/mariabackup/datasink.h +++ b/extra/mariabackup/datasink.h @@ -48,7 +48,7 @@ typedef struct { struct datasink_struct { ds_ctxt_t *(*init)(const char *root); ds_file_t *(*open)(ds_ctxt_t *ctxt, const char *path, MY_STAT *stat); - int (*write)(ds_file_t *file, const void *buf, size_t len); + int (*write)(ds_file_t *file, const unsigned char *buf, size_t len); int (*close)(ds_file_t *file); void (*deinit)(ds_ctxt_t *ctxt); }; diff --git a/extra/mariabackup/ds_buffer.c b/extra/mariabackup/ds_buffer.c index 4bb314c0f50b4cde6e74cd9ca801958a9aaab4a5..8e13e878953c4783347ee0082e331f569c5698a9 100644 --- a/extra/mariabackup/ds_buffer.c +++ b/extra/mariabackup/ds_buffer.c @@ -45,7 +45,7 @@ typedef struct { static ds_ctxt_t *buffer_init(const char *root); static ds_file_t *buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat); -static int buffer_write(ds_file_t *file, const void *buf, size_t len); +static int buffer_write(ds_file_t *file, const uchar *buf, size_t len); static int buffer_close(ds_file_t *file); static void buffer_deinit(ds_ctxt_t *ctxt); @@ -119,7 +119,7 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) } static int -buffer_write(ds_file_t *file, const void *buf, size_t len) +buffer_write(ds_file_t *file, const uchar *buf, size_t len) { ds_buffer_file_t *buffer_file; @@ -142,7 +142,7 @@ buffer_write(ds_file_t *file, const void *buf, size_t len) buffer_file->pos = 0; - buf = (const char *) buf + bytes; + buf += bytes; len -= bytes; } else { /* We don't have any buffered bytes, just write diff --git a/extra/mariabackup/ds_compress.c b/extra/mariabackup/ds_compress.c index 15801c8abd412e5ee5c8562b3cf28ae64a2a7dde..88f508573620de505de3d1e789b61c02c4e440d4 100644 --- a/extra/mariabackup/ds_compress.c +++ b/extra/mariabackup/ds_compress.c @@ -65,7 +65,7 @@ extern ulonglong xtrabackup_compress_chunk_size; static ds_ctxt_t *compress_init(const char *root); static ds_file_t *compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat); -static int compress_write(ds_file_t *file, const void *buf, size_t len); +static int compress_write(ds_file_t *file, const uchar *buf, size_t len); static int compress_close(ds_file_t *file); static void compress_deinit(ds_ctxt_t *ctxt); @@ -178,7 +178,7 @@ compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) static int -compress_write(ds_file_t *file, const void *buf, size_t len) +compress_write(ds_file_t *file, const uchar *buf, size_t len) { ds_compress_file_t *comp_file; ds_compress_ctxt_t *comp_ctxt; diff --git a/extra/mariabackup/ds_local.c b/extra/mariabackup/ds_local.c deleted file mode 100644 index 3e2b1e0129bb88ba0536247bdbfe168ef7f6eb2d..0000000000000000000000000000000000000000 --- a/extra/mariabackup/ds_local.c +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************** -Copyright (c) 2011-2013 Percona LLC and/or its affiliates. - -Local datasink implementation for XtraBackup. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -*******************************************************/ - -#include -#include -#include -#include "common.h" -#include "datasink.h" - -typedef struct { - File fd; -} ds_local_file_t; - -static ds_ctxt_t *local_init(const char *root); -static ds_file_t *local_open(ds_ctxt_t *ctxt, const char *path, - MY_STAT *mystat); -static int local_write(ds_file_t *file, const void *buf, size_t len); -static int local_close(ds_file_t *file); -static void local_deinit(ds_ctxt_t *ctxt); - -datasink_t datasink_local = { - &local_init, - &local_open, - &local_write, - &local_close, - &local_deinit -}; - -static -ds_ctxt_t * -local_init(const char *root) -{ - ds_ctxt_t *ctxt; - - if (my_mkdir(root, 0777, MYF(0)) < 0 - && my_errno != EEXIST && my_errno != EISDIR) - { - char errbuf[MYSYS_STRERROR_SIZE]; - my_strerror(errbuf, sizeof(errbuf),my_errno); - my_error(EE_CANT_MKDIR, MYF(ME_BELL | ME_WAITTANG), - root, my_errno,errbuf, my_errno); - return NULL; - } - - ctxt = my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE)); - - ctxt->root = my_strdup(root, MYF(MY_FAE)); - - return ctxt; -} - -static -ds_file_t * -local_open(ds_ctxt_t *ctxt, const char *path, - MY_STAT *mystat __attribute__((unused))) -{ - char fullpath[FN_REFLEN]; - char dirpath[FN_REFLEN]; - size_t dirpath_len; - size_t path_len; - ds_local_file_t *local_file; - ds_file_t *file; - File fd; - - fn_format(fullpath, path, ctxt->root, "", MYF(MY_RELATIVE_PATH)); - - /* Create the directory if needed */ - dirname_part(dirpath, fullpath, &dirpath_len); - if (my_mkdir(dirpath, 0777, MYF(0)) < 0 && my_errno != EEXIST) { - char errbuf[MYSYS_STRERROR_SIZE]; - my_strerror(errbuf, sizeof(errbuf), my_errno); - my_error(EE_CANT_MKDIR, MYF(ME_BELL | ME_WAITTANG), - dirpath, my_errno, errbuf); - return NULL; - } - - fd = my_create(fullpath, 0, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, - MYF(MY_WME)); - if (fd < 0) { - return NULL; - } - - path_len = strlen(fullpath) + 1; /* terminating '\0' */ - - file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + - sizeof(ds_local_file_t) + - path_len, - MYF(MY_FAE)); - local_file = (ds_local_file_t *) (file + 1); - - local_file->fd = fd; - - file->path = (char *) local_file + sizeof(ds_local_file_t); - memcpy(file->path, fullpath, path_len); - - file->ptr = local_file; - - return file; -} - -static -int -local_write(ds_file_t *file, const void *buf, size_t len) -{ - File fd = ((ds_local_file_t *) file->ptr)->fd; - - if (!my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { - posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); - return 0; - } - - return 1; -} - -static -int -local_close(ds_file_t *file) -{ - File fd = ((ds_local_file_t *) file->ptr)->fd; - - my_free(file); - - my_sync(fd, MYF(MY_WME)); - - return my_close(fd, MYF(MY_WME)); -} - -static -void -local_deinit(ds_ctxt_t *ctxt) -{ - my_free(ctxt->root); - my_free(ctxt); -} diff --git a/extra/mariabackup/ds_local.cc b/extra/mariabackup/ds_local.cc new file mode 100644 index 0000000000000000000000000000000000000000..f1068d251dc594636ed355c112f28261a344cee9 --- /dev/null +++ b/extra/mariabackup/ds_local.cc @@ -0,0 +1,259 @@ +/****************************************************** +Copyright (c) 2011-2013 Percona LLC and/or its affiliates. + +Local datasink implementation for XtraBackup. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +*******************************************************/ + +#include +#include +#include +#include +#include "common.h" +#include "datasink.h" +#include "univ.i" +#include "fsp0fsp.h" +#ifdef _WIN32 +#include +#endif + +typedef struct { + File fd; + my_bool init_ibd_done; + my_bool is_ibd; + my_bool compressed; + size_t pagesize; +} ds_local_file_t; + +static ds_ctxt_t *local_init(const char *root); +static ds_file_t *local_open(ds_ctxt_t *ctxt, const char *path, + MY_STAT *mystat); +static int local_write(ds_file_t *file, const uchar *buf, size_t len); +static int local_close(ds_file_t *file); +static void local_deinit(ds_ctxt_t *ctxt); + +extern "C" { +datasink_t datasink_local = { + &local_init, + &local_open, + &local_write, + &local_close, + &local_deinit +}; +} + +static +ds_ctxt_t * +local_init(const char *root) +{ + ds_ctxt_t *ctxt; + + if (my_mkdir(root, 0777, MYF(0)) < 0 + && my_errno != EEXIST && my_errno != EISDIR) + { + char errbuf[MYSYS_STRERROR_SIZE]; + my_strerror(errbuf, sizeof(errbuf),my_errno); + my_error(EE_CANT_MKDIR, MYF(ME_BELL | ME_WAITTANG), + root, my_errno,errbuf, my_errno); + return NULL; + } + + ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE)); + + ctxt->root = my_strdup(root, MYF(MY_FAE)); + + return ctxt; +} + +static +ds_file_t * +local_open(ds_ctxt_t *ctxt, const char *path, + MY_STAT *mystat __attribute__((unused))) +{ + char fullpath[FN_REFLEN]; + char dirpath[FN_REFLEN]; + size_t dirpath_len; + size_t path_len; + ds_local_file_t *local_file; + ds_file_t *file; + File fd; + + fn_format(fullpath, path, ctxt->root, "", MYF(MY_RELATIVE_PATH)); + + /* Create the directory if needed */ + dirname_part(dirpath, fullpath, &dirpath_len); + if (my_mkdir(dirpath, 0777, MYF(0)) < 0 && my_errno != EEXIST) { + char errbuf[MYSYS_STRERROR_SIZE]; + my_strerror(errbuf, sizeof(errbuf), my_errno); + my_error(EE_CANT_MKDIR, MYF(ME_BELL | ME_WAITTANG), + dirpath, my_errno, errbuf); + return NULL; + } + + fd = my_create(fullpath, 0, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, + MYF(MY_WME)); + if (fd < 0) { + return NULL; + } + + path_len = strlen(fullpath) + 1; /* terminating '\0' */ + + file = (ds_file_t *) my_malloc(sizeof(ds_file_t) + + sizeof(ds_local_file_t) + + path_len, + MYF(MY_FAE)); + local_file = (ds_local_file_t *) (file + 1); + + local_file->fd = fd; + local_file->init_ibd_done = 0; + local_file->is_ibd = (path_len > 5) && !strcmp(fullpath + path_len - 5, ".ibd"); + local_file->compressed = 0; + local_file->pagesize = 0; + file->path = (char *) local_file + sizeof(ds_local_file_t); + memcpy(file->path, fullpath, path_len); + + file->ptr = local_file; + + return file; +} + +/* Calculate size of data without trailing zero bytes. */ +static size_t trim_binary_zeros(uchar *buf, size_t pagesize) +{ + size_t i; + for (i = pagesize; (i > 0) && (buf[i - 1] == 0); i--) {}; + return i; +} + + +/* Write data to the output file, and punch "holes" if needed. */ +static int write_compressed(File fd, uchar *data, size_t len, size_t pagesize) +{ + uchar *ptr = data; + for (size_t written= 0; written < len;) + { + size_t n_bytes = MY_MIN(pagesize, len - written); + size_t datasize= trim_binary_zeros(ptr,n_bytes); + if (datasize > 0) { + if (!my_write(fd, ptr, datasize, MYF(MY_WME | MY_NABP))) + posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); + else + return 1; + } + if (datasize < n_bytes) { + /* This punches a "hole" in the file. */ + size_t hole_bytes = n_bytes - datasize; + if (my_seek(fd, hole_bytes, MY_SEEK_CUR, MYF(MY_WME | MY_NABP)) + == MY_FILEPOS_ERROR) + return 1; + } + written += n_bytes; + ptr += n_bytes; + } + return 0; +} + + +/* Calculate Innodb tablespace specific data, when first page is written. + We're interested in page compression and page size. +*/ +static void init_ibd_data(ds_local_file_t *local_file, const uchar *buf, size_t len) +{ + if (len < FIL_PAGE_DATA + FSP_SPACE_FLAGS) { + /* Weird, bail out.*/ + return; + } + + ulint flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]); + ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags); + local_file->pagesize= ssize == 0 ? UNIV_PAGE_SIZE_ORIG : ((UNIV_ZIP_SIZE_MIN >> 1) << ssize); + local_file->compressed = (my_bool)FSP_FLAGS_HAS_PAGE_COMPRESSION(flags); + +#if defined(_WIN32) && (MYSQL_VERSION_ID > 100200) + /* Make compressed file sparse, on Windows. + In 10.1, we do not use sparse files. */ + if (local_file->compressed) { + HANDLE handle= my_get_osfhandle(local_file->fd); + if (!DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, NULL, 0)) { + fprintf(stderr, "Warning: cannot make file sparse"); + local_file->compressed = 0; + } + } +#endif +} + + +static +int +local_write(ds_file_t *file, const uchar *buf, size_t len) +{ + uchar *b = (uchar*)buf; + ds_local_file_t *local_file= (ds_local_file_t *)file->ptr; + File fd = local_file->fd; + + if (local_file->is_ibd && !local_file->init_ibd_done) { + init_ibd_data(local_file, b , len); + local_file->init_ibd_done= 1; + } + + if (local_file->compressed) { + return write_compressed(fd, b, len, local_file->pagesize); + } + + if (!my_write(fd, b , len, MYF(MY_WME | MY_NABP))) { + posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); + return 0; + } + return 1; +} + +/* Set EOF at file's current position.*/ +static int set_eof(File fd) +{ +#ifdef _WIN32 + return !SetEndOfFile(my_get_osfhandle(fd)); +#elif defined(HAVE_FTRUNCATE) + return ftruncate(fd, my_tell(fd, MYF(MY_WME))); +#else +#error no ftruncate +#endif +} + + +static +int +local_close(ds_file_t *file) +{ + ds_local_file_t *local_file= (ds_local_file_t *)file->ptr; + File fd = local_file->fd; + int ret= 0; + + if (local_file->compressed) { + ret = set_eof(fd); + } + + my_close(fd, MYF(MY_WME)); + my_free(file); + return ret; +} + +static +void +local_deinit(ds_ctxt_t *ctxt) +{ + my_free(ctxt->root); + my_free(ctxt); +} diff --git a/extra/mariabackup/ds_local.h b/extra/mariabackup/ds_local.h index b0f0f04030c2a1e5000852d951c2d9253a6fec6b..e30906b575d1eca913627fc9a3714d2e541fb2a6 100644 --- a/extra/mariabackup/ds_local.h +++ b/extra/mariabackup/ds_local.h @@ -23,6 +23,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "datasink.h" -extern datasink_t datasink_local; +#ifdef __cplusplus +extern "C" +#else +extern +#endif + +datasink_t datasink_local; #endif diff --git a/extra/mariabackup/ds_stdout.c b/extra/mariabackup/ds_stdout.c index 91a514ddf6444a27eebf3500863c2037a0501011..391a34551951b1cbad66b1ca5fa7938300ccdbca 100644 --- a/extra/mariabackup/ds_stdout.c +++ b/extra/mariabackup/ds_stdout.c @@ -30,7 +30,7 @@ typedef struct { static ds_ctxt_t *stdout_init(const char *root); static ds_file_t *stdout_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat); -static int stdout_write(ds_file_t *file, const void *buf, size_t len); +static int stdout_write(ds_file_t *file, const uchar *buf, size_t len); static int stdout_close(ds_file_t *file); static void stdout_deinit(ds_ctxt_t *ctxt); @@ -91,7 +91,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)), static int -stdout_write(ds_file_t *file, const void *buf, size_t len) +stdout_write(ds_file_t *file, const uchar *buf, size_t len) { File fd = ((ds_stdout_file_t *) file->ptr)->fd; diff --git a/extra/mariabackup/ds_tmpfile.c b/extra/mariabackup/ds_tmpfile.c index b039d83ba03e02a1166567923dfc15b264aa7793..27a8d9688f44e68782cc246be9e9683a7ada9387 100644 --- a/extra/mariabackup/ds_tmpfile.c +++ b/extra/mariabackup/ds_tmpfile.c @@ -41,7 +41,7 @@ typedef struct { static ds_ctxt_t *tmpfile_init(const char *root); static ds_file_t *tmpfile_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat); -static int tmpfile_write(ds_file_t *file, const void *buf, size_t len); +static int tmpfile_write(ds_file_t *file, const uchar *buf, size_t len); static int tmpfile_close(ds_file_t *file); static void tmpfile_deinit(ds_ctxt_t *ctxt); @@ -143,7 +143,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path, } static int -tmpfile_write(ds_file_t *file, const void *buf, size_t len) +tmpfile_write(ds_file_t *file, const uchar *buf, size_t len) { File fd = ((ds_tmp_file_t *) file->ptr)->fd; diff --git a/extra/mariabackup/ds_xbstream.c b/extra/mariabackup/ds_xbstream.c index 42924a72d7f80ccfa6af8a84a5fe9f63a8eaf7b9..544929fb24c01270210b79509e50b191b5b878a1 100644 --- a/extra/mariabackup/ds_xbstream.c +++ b/extra/mariabackup/ds_xbstream.c @@ -41,7 +41,7 @@ General streaming interface */ static ds_ctxt_t *xbstream_init(const char *root); static ds_file_t *xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat); -static int xbstream_write(ds_file_t *file, const void *buf, size_t len); +static int xbstream_write(ds_file_t *file, const uchar *buf, size_t len); static int xbstream_close(ds_file_t *file); static void xbstream_deinit(ds_ctxt_t *ctxt); @@ -166,7 +166,7 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) static int -xbstream_write(ds_file_t *file, const void *buf, size_t len) +xbstream_write(ds_file_t *file, const uchar *buf, size_t len) { ds_stream_file_t *stream_file; xb_wstream_file_t *xbstream_file; diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc index 7e97b2584898673468f53969741db2369a75d3c7..a134abb314d8c282399823964b3da0298b09e9c2 100644 --- a/extra/mariabackup/innobackupex.cc +++ b/extra/mariabackup/innobackupex.cc @@ -255,7 +255,7 @@ static struct my_option ibx_long_options[] = {"galera-info", OPT_GALERA_INFO, "This options creates the " "xtrabackup_galera_info file which contains the local node state at " "the time of the backup. Option should be used when performing the " - "backup of Percona-XtraDB-Cluster. Has no effect when backup locks " + "backup of MariaDB Galera Cluster. Has no effect when backup locks " "are used to create the backup.", (uchar *) &opt_ibx_galera_info, (uchar *) &opt_ibx_galera_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mariabackup/xbcloud.cc b/extra/mariabackup/xbcloud.cc index 56661b03dd083343da0398907973965432eb1f0b..878b4c81023d3fdaa205a025500425b59091c98f 100644 --- a/extra/mariabackup/xbcloud.cc +++ b/extra/mariabackup/xbcloud.cc @@ -443,9 +443,7 @@ int parse_args(int argc, char **argv) exit(EXIT_FAILURE); } - if (load_defaults("my", load_default_groups, &argc, &argv)) { - exit(EXIT_FAILURE); - } + load_defaults_or_exit("my", load_default_groups, &argc, &argv); if (handle_options(&argc, &argv, my_long_options, get_one_option)) { exit(EXIT_FAILURE); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 2228e542dc71d13f263c67cb0c3cccc591c2ee8c..84f57bde64f50c2fa2c89b62f013af8895bb88ac 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -203,6 +203,10 @@ static ulong max_buf_pool_modified_pct; /* Ignored option (--log) for MySQL option compatibility */ char* log_ignored_opt = NULL; + +extern my_bool opt_use_ssl; +my_bool opt_ssl_verify_server_cert; + /* === metadata of backup === */ #define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints" char metadata_type[30] = ""; /*[full-backuped|log-applied| @@ -360,9 +364,6 @@ uint opt_safe_slave_backup_timeout = 0; const char *opt_history = NULL; -#if defined(HAVE_OPENSSL) -my_bool opt_ssl_verify_server_cert = FALSE; -#endif /* Whether xtrabackup_binlog_info should be created on recovery */ static bool recover_binlog_info; @@ -453,6 +454,7 @@ typedef struct { } data_thread_ctxt_t; /* ======== for option and variables ======== */ +#include <../../client/client_priv.h> enum options_xtrabackup { @@ -528,8 +530,6 @@ enum options_xtrabackup OPT_INNODB_LOG_CHECKSUM_ALGORITHM, OPT_XTRA_INCREMENTAL_FORCE_SCAN, OPT_DEFAULTS_GROUP, - OPT_OPEN_FILES_LIMIT, - OPT_PLUGIN_DIR, OPT_PLUGIN_LOAD, OPT_INNODB_ENCRYPT_LOG, OPT_CLOSE_FILES, @@ -694,7 +694,7 @@ struct my_option xb_client_options[] = {"galera-info", OPT_GALERA_INFO, "This options creates the " "xtrabackup_galera_info file which contains the local node state at " "the time of the backup. Option should be used when performing the " - "backup of Percona-XtraDB-Cluster. Has no effect when backup locks " + "backup of MariaDB Galera Cluster. Has no effect when backup locks " "are used to create the backup.", (uchar *) &opt_galera_info, (uchar *) &opt_galera_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -915,9 +915,9 @@ struct my_option xb_client_options[] = {"secure-auth", OPT_XB_SECURE_AUTH, "Refuse client connecting to server if it" " uses old (pre-4.1.1) protocol.", &opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - +#define MYSQL_CLIENT #include "sslopt-longopts.h" - +#undef MYSQL_CLIENT { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1388,7 +1388,9 @@ xb_get_one_option(int optid, } } break; +#define MYSQL_CLIENT #include "sslopt-case.h" +#undef MYSQL_CLIENT case '?': usage(); @@ -3079,6 +3081,85 @@ xb_fil_io_init(void) fsp_init(); } +/** Assign srv_undo_space_id_start variable if there are undo tablespace present. +Read the TRX_SYS page from ibdata1 file and get the minimum space id from +the first slot rollback segments of TRX_SYS_PAGE_NO. +@retval DB_ERROR if file open or page read failed. +@retval DB_SUCCESS if srv_undo_space_id assigned successfully. */ +static dberr_t xb_assign_undo_space_start() +{ + ulint dirnamelen; + char name[1000]; + pfs_os_file_t file; + byte* buf; + byte* page; + ibool ret; + dberr_t error = DB_SUCCESS; + ulint space, page_no; + + if (srv_undo_tablespaces == 0) { + return error; + } + + srv_normalize_path_for_win(srv_data_home); + dirnamelen = strlen(srv_data_home); + memcpy(name, srv_data_home, dirnamelen); + + if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) { + name[dirnamelen++] = SRV_PATH_SEPARATOR; + } + + ut_snprintf(name + dirnamelen, (sizeof name) - dirnamelen, + "%s", "ibdata1"); + + file = os_file_create(innodb_file_data_key, name, OS_FILE_OPEN, + OS_FILE_NORMAL, OS_DATA_FILE, &ret, 0); + + if (ret == FALSE) { + fprintf(stderr, "InnoDB: Error in opening %s\n", name); + return DB_ERROR; + } + + buf = static_cast(ut_malloc(2 * UNIV_PAGE_SIZE)); + page = static_cast(ut_align(buf, UNIV_PAGE_SIZE)); + +retry: + ret = os_file_read(file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE, + UNIV_PAGE_SIZE); + + if (!ret) { + fprintf(stderr, "InnoDB: Reading TRX_SYS page failed."); + error = DB_ERROR; + goto func_exit; + } + + /* TRX_SYS page can't be compressed or encrypted. */ + if (buf_page_is_corrupted(false, page, 0, NULL)) { + goto retry; + } + + /* 0th slot always points to system tablespace. + 1st slot should point to first undotablespace which is minimum. */ + + page_no = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS + + TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_PAGE_NO + page, MLOG_4BYTES); + ut_ad(page_no != FIL_NULL); + + space = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS + + TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_SPACE + page, MLOG_4BYTES); + + srv_undo_space_id_start = space; + +func_exit: + ut_free(buf); + ret = os_file_close(file); + ut_a(ret); + + return error; +} + /**************************************************************************** Populates the tablespace memory cache by scanning for and opening data files. @returns DB_SUCCESS or error code.*/ @@ -3132,6 +3213,12 @@ xb_load_tablespaces(void) /* Add separate undo tablespaces to fil_system */ + err = xb_assign_undo_space_start(); + + if (err != DB_SUCCESS) { + return err; + } + err = srv_undo_tablespaces_init(FALSE, TRUE, srv_undo_tablespaces, @@ -4881,8 +4968,6 @@ xtrabackup_apply_delta( posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL); - os_file_set_nocache(src_file, src_path, "OPEN"); - dst_file = xb_delta_open_matching_space( dbname, space_name, info.space_id, info.zip_size, dst_path, sizeof(dst_path), &success); @@ -4893,8 +4978,6 @@ xtrabackup_apply_delta( posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); - os_file_set_nocache(dst_file, dst_path, "OPEN"); - /* allocate buffer for incremental backup (4096 pages) */ incremental_buffer_base = static_cast (ut_malloc((page_size / 4 + 1) * @@ -4994,6 +5077,13 @@ xtrabackup_apply_delta( } } + /* Free file system buffer cache after the batch was written. */ +#ifdef __linux__ + os_file_flush_func(dst_file); +#endif + posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); + + incremental_buffers++; } @@ -6350,10 +6440,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) *argv_client = argv; *argv_server = argv; - if (load_defaults(conf_file, xb_server_default_groups, - &argc_server, argv_server)) { - exit(EXIT_FAILURE); - } + load_defaults_or_exit(conf_file, xb_server_default_groups, + &argc_server, argv_server); int n; for (n = 0; (*argv_server)[n]; n++) {}; @@ -6403,10 +6491,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) xb_server_options, xb_get_one_option))) exit(ho_error); - if (load_defaults(conf_file, xb_client_default_groups, - &argc_client, argv_client)) { - exit(EXIT_FAILURE); - } + load_defaults_or_exit(conf_file, xb_client_default_groups, + &argc_client, argv_client); for (n = 0; (*argv_client)[n]; n++) {}; argc_client = n; @@ -6618,6 +6704,10 @@ int main(int argc, char **argv) xtrabackup_incremental = NULL; } + if (xtrabackup_stream && !xtrabackup_backup) { + msg("Warning: --stream parameter is ignored, it only works together with --backup.\n"); + } + if (!xb_init()) { exit(EXIT_FAILURE); } diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 78940e02ca43f998a039a1bc38efce945eba8be7..07c95a79ddc7012575880a05b373b05c86f82079 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -206,6 +206,9 @@ int main(int argc, char **argv) if ((error= load_defaults(config_file, (const char **) load_default_groups, &count, &arguments))) { + my_end(0); + if (error == 4) + return 0; if (verbose && opt_defaults_file_used) { if (error == 1) @@ -216,8 +219,7 @@ int main(int argc, char **argv) fprintf(stderr, "WARNING: Defaults file '%s' is not a regular file!\n", config_file); } - error= 2; - exit(error); + return 2; } for (argument= arguments+1 ; *argument ; argument++) diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 407e4092ccc0aa3dbbd16329d07b5bc725a974f6..6e181a997bd95e3aa78147d09c62aae9965a2a3f 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -788,6 +788,16 @@ int DoProcessReply(SSL& ssl) needHdr = true; else { buffer >> hdr; + /* + According to RFC 4346 (see "7.4.1.3. Server Hello"), the Server Hello + packet needs to specify the highest supported TLS version, but not + higher than what client requests. YaSSL highest supported version is + TLSv1.1 (=3.2) - if the client requests a higher version, downgrade it + here to 3.2. + See also Appendix E of RFC 5246 (TLS 1.2) + */ + if (hdr.version_.major_ == 3 && hdr.version_.minor_ > 2) + hdr.version_.minor_ = 2; ssl.verifyState(hdr); } diff --git a/include/heap.h b/include/heap.h index 724cf6c5f98a95e019e6a02d9ef378fe43aa7c8c..e92f649b87bd73350a9b545aa7f016c2c98ba5c1 100644 --- a/include/heap.h +++ b/include/heap.h @@ -144,6 +144,7 @@ typedef struct st_heap_share uint key_version; /* Updated on key change */ uint file_version; /* Update on clear */ uint reclength; /* Length of one record */ + uint visible; /* Offset to the visible/deleted mark */ uint changed; uint keys,max_key_length; uint currently_disabled_keys; /* saved value from "keys" when disabled */ diff --git a/include/my_default.h b/include/my_default.h index 0ed94b094922c991ea6cfba62d3182d01e324596..bd3a21f03a89a732ec8b6ecb8c8aa16d1e9ec27e 100644 --- a/include/my_default.h +++ b/include/my_default.h @@ -45,6 +45,13 @@ extern void free_defaults(char **argv); extern void my_print_default_files(const char *conf_file); extern void print_defaults(const char *conf_file, const char **groups); + +/** Simplify load_defaults() common use */ +#define load_defaults_or_exit(A, B, C, D) switch (load_defaults(A, B, C, D)) { \ + case 0: break; \ + case 4: my_end(0); exit(0); \ + default: my_end(0); exit(1); } + C_MODE_END #endif /* MY_DEFAULT_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index acc54398cf88ed31fa3379b4766c130b2908413a..dcfd607b455769a5a31a00b1911fa4510b4904a7 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -593,8 +593,15 @@ typedef SOCKET_SIZE_TYPE size_socket; #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif +#ifdef __GLIBC__ +#define STR_O_CLOEXEC "e" +#else +#define STR_O_CLOEXEC "" +#endif #ifndef SOCK_CLOEXEC #define SOCK_CLOEXEC 0 +#else +#define HAVE_SOCK_CLOEXEC #endif /* additional file share flags for win32 */ diff --git a/include/my_systemd.h b/include/my_service_manager.h similarity index 72% rename from include/my_systemd.h rename to include/my_service_manager.h index bef75576422bd342d5a47af347bf3bc33678c6c4..4d88e992b5e336e76d4a62c7df8cbaac3beb1834 100644 --- a/include/my_systemd.h +++ b/include/my_service_manager.h @@ -16,8 +16,8 @@ */ -#ifndef MY_SYSTEMD_INCLUDED -#define MY_SYSTEMD_INCLUDED +#ifndef MY_SERVICE_MANAGER_INCLUDED +#define MY_SERVICE_MANAGER_INCLUDED #if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY) /* @@ -26,9 +26,14 @@ */ #define __STDC_FORMAT_MACROS #include +/** INTERVAL in seconds followed by printf style status */ +#define service_manager_extend_timeout(INTERVAL, FMTSTR, ...) \ + sd_notifyf(0, "STATUS=" FMTSTR "\nEXTEND_TIMEOUT_USEC=%u\n", ##__VA_ARGS__, INTERVAL * 1000000) + #else #define sd_notify(X, Y) #define sd_notifyf(E, F, ...) +#define service_manager_extend_timeout(I, FMTSTR, ...) #endif -#endif /* MY_SYSTEMD_INCLUDED */ +#endif /* MY_SERVICE_MANAGER_INCLUDED */ diff --git a/include/my_sys.h b/include/my_sys.h index 110a2ee9af39db9efd09a61fc21653308421e71e..1c5649812d10b408a47e38307a0db73c960ead16 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -112,6 +112,7 @@ typedef struct my_aio_result { #define ME_JUST_INFO 1024 /**< not error but just info */ #define ME_JUST_WARNING 2048 /**< not error but just warning */ #define ME_FATALERROR 4096 /* Fatal statement error */ +#define ME_LOG_AS_WARN 8192 /* is error but error-logged as warning */ /* Bits in last argument to fn_format */ #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ diff --git a/include/my_valgrind.h b/include/my_valgrind.h index e3aa11ee355d71bada18f04bf5b3077a2ab8af7e..c488aaf1052c81419a6a97eed89f4964936b6423 100644 --- a/include/my_valgrind.h +++ b/include/my_valgrind.h @@ -35,6 +35,8 @@ # define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len) #elif defined(__SANITIZE_ADDRESS__) # include +/* How to do manual poisoning: +https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */ # define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len) # define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len) # define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0) diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h index 1dbe8c7eb22ac375a7a015bedcc30c0c5343cab0..fc0a3ce2eb00f22fd1799435c74ae5bf1b2356c5 100644 --- a/include/mysql/psi/mysql_socket.h +++ b/include/mysql/psi/mysql_socket.h @@ -562,6 +562,12 @@ inline_mysql_socket_socket (key, (const my_socket*)&mysql_socket.fd, NULL, 0); } #endif + + /* SOCK_CLOEXEC isn't always a number - can't preprocessor compare */ +#if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) && !defined(HAVE_SOCK_CLOEXEC) + (void) fcntl(mysql_socket.fd, F_SETFD, FD_CLOEXEC); +#endif + return mysql_socket; } diff --git a/include/mysql_com.h b/include/mysql_com.h index 678ff0b7186a7ebd3c567ffe65204d5daed20af7..dd55daf77aa584c133faf181f8ac9fb818629be6 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2010, 2013, Monty Program Ab + Copyright (c) 2010, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/sql_common.h b/include/sql_common.h index 39b8ce18517f5a20d34dee1baf24ff4115c41574..9c67034d798ee23a89337b15eeb7095122f7b249 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -1,7 +1,7 @@ #ifndef SQL_COMMON_INCLUDED #define SQL_COMMON_INCLUDED /* Copyright (c) 2003, 2012, Oracle and/or its affiliates. - Copyright (c) 2010, 2012, Monty Program Ab + Copyright (c) 2010, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test index ed7583137704b97c00459c63e7c24708c879896d..20c79ed4b3b945bc12db27698171e5509b15f0d1 100644 --- a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test +++ b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test @@ -32,345 +32,97 @@ INSERT INTO tt_2(ddl_case) VALUES(0); --echo # CHECK IMPLICT COMMIT --echo ######################################################################### SET AUTOCOMMIT= 0; -let $ddl_cases= 43; -while ($ddl_cases >= 1) -{ - --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- - let $in_temporary= no; - let $ok= yes; - # - # In SBR and MIXED modes, the commit event is usually the third event in the - # binary log: - # - # 1: BEGIN - # 2: INSERT - # 3: COMMIT - # 4: DDL EVENT which triggered the previous commmit. - # - if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) - { - let $commit_event_row_number= 3; - } - # - # In RBR mode, the commit event is usually the fourth event in the binary log: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: COMMIT - # 5: DDL EVENT which triggered the previous commmit. - # - if (`select @@binlog_format = 'ROW'`) - { - let $commit_event_row_number= 4; - } - - let $first_binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1); - --enable_query_log - eval INSERT INTO tt_1(ddl_case) VALUES ($ddl_cases); - if ($ddl_cases == 43) - { - let $cmd= CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; - } - if ($ddl_cases == 42) - { - let $cmd= DROP FUNCTION myfunc_int; - } - if ($ddl_cases == 41) - { - let $cmd= LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; - } - if ($ddl_cases == 40) - { - let $cmd= LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; - } - if ($ddl_cases == 39) - { - let $cmd= ANALYZE TABLE nt_1; - } - if ($ddl_cases == 38) - { - let $cmd= CHECK TABLE nt_1; - } - if ($ddl_cases == 37) - { - let $cmd= OPTIMIZE TABLE nt_1; - } - if ($ddl_cases == 36) - { - let $cmd= REPAIR TABLE nt_1; - } - if ($ddl_cases == 35) - { - let $cmd= LOCK TABLES tt_1 WRITE; - } - if ($ddl_cases == 34) - { - let $cmd= UNLOCK TABLES; - } - if ($ddl_cases == 33) - { - let $cmd= CREATE USER 'user'@'localhost'; - } - if ($ddl_cases == 32) - { - let $cmd= GRANT ALL ON *.* TO 'user'@'localhost'; - } - if ($ddl_cases == 31) - { - let $cmd= SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); - } - if ($ddl_cases == 30) - { - let $cmd= REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; - } - if ($ddl_cases == 29) - { - let $cmd= RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; - } - if ($ddl_cases == 28) - { - let $cmd= DROP USER 'user_new'@'localhost'; - } - if ($ddl_cases == 27) - { - let $cmd= CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; - } - if ($ddl_cases == 26) - { - let $cmd= ALTER EVENT evt COMMENT 'evt'; - } - if ($ddl_cases == 25) - { - let $cmd= DROP EVENT evt; - } - if ($ddl_cases == 24) - { - let $cmd= CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; - } - if ($ddl_cases == 23) - { - let $cmd= DROP TRIGGER tr; - # - # In RBR mode, due to the trigger the tt_2 is also updated: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: TABLE MAP EVENT - # 4: ROW EVENT - # 5: COMMIT - # 6: DDL EVENT which triggered the previous commmit. - # - if (`select @@binlog_format = 'ROW'`) - { - let $commit_event_row_number= 5; - } - } - if ($ddl_cases == 22) - { - let $cmd= CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; - } - if ($ddl_cases == 21) - { - let $cmd= ALTER FUNCTION fc COMMENT 'fc'; - } - if ($ddl_cases == 20) - { - let $cmd= DROP FUNCTION fc; - } - if ($ddl_cases == 19) - { - let $cmd= CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; - } - if ($ddl_cases == 18) - { - let $cmd= ALTER PROCEDURE pc COMMENT 'pc'; - } - if ($ddl_cases == 17) - { - let $cmd= DROP PROCEDURE pc; - } - if ($ddl_cases == 16) - { - let $cmd= CREATE VIEW v AS SELECT * FROM tt_1; - } - if ($ddl_cases == 15) - { - let $cmd= ALTER VIEW v AS SELECT * FROM tt_1; - } - if ($ddl_cases == 14) - { - let $cmd= DROP VIEW v; - } - if ($ddl_cases == 13) - { - let $cmd= CREATE INDEX ix ON tt_1(ddl_case); - } - if ($ddl_cases == 12) - { - let $cmd= DROP INDEX ix ON tt_1; - } - if ($ddl_cases == 11) - { - let $cmd= CREATE TEMPORARY TABLE tt_xx (a int); - let $in_temporary= yes; - # In SBR and MIXED modes, the DDL statement is written to the binary log but - # does not commit the current transaction. - # - # 1: BEGIN - # 2: CREATE TEMPORARY - # 3: INSERT - # 4: COMMIT - # - # In RBR the transaction is not committed either and the statement is not - # written to the binary log: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: COMMIT - # - if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'` ) - { - let $commit_event_row_number= 4; - } - } - if ($ddl_cases == 10) - { - let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int); - # - # In MIXED mode, the changes are logged as rows and we have what follows: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: COMMIT - # 5: DDL EVENT which triggered the previous commmit. - # - if (`select @@binlog_format = 'MIXED'`) - { - let $commit_event_row_number= 4; - } - } - if ($ddl_cases == 9) - { - let $cmd= ALTER TABLE tt_xx RENAME new_tt_xx; - # - # In MIXED mode, the changes are logged as rows and we have what follows: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: COMMIT - # 5: DDL EVENT which triggered the previous commmit. - # - if (`select @@binlog_format = 'MIXED'`) - { - let $commit_event_row_number= 4; - } - } - if ($ddl_cases == 8) - { - let $cmd= DROP TEMPORARY TABLE IF EXISTS new_tt_xx; - let $in_temporary= yes; - # - # In SBR and MIXED modes, the DDL statement is written to the binary log - # but does not commit the current transaction: - # - # In SBR, we have what follows: - # - # 1: BEGIN - # 2: INSERT - # 3: DROP TEMPORARY - # 4: COMMIT - # - # In RBR the transaction is not committed either and the statement is not - # written to the binary log: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: COMMIT - # - if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'ROW'`) - { - let $commit_event_row_number= 4; - } - # In MIXED mode, the changes are logged as rows and we have what follows: - # - # 1: BEGIN - # 2: TABLE MAP EVENT - # 3: ROW EVENT - # 4: DROP TEMPORARY - # 5: COMMIT - # - if (`select @@binlog_format = 'MIXED'`) - { - let $commit_event_row_number= 5; - } - } - if ($ddl_cases == 7) - { - let $cmd= CREATE TABLE tt_xx (a int); - } - if ($ddl_cases == 6) - { - let $cmd= ALTER TABLE tt_xx ADD COLUMN (b int); - } - if ($ddl_cases == 5) - { - let $cmd= RENAME TABLE tt_xx TO new_tt_xx; - } - if ($ddl_cases == 4) - { - let $cmd= TRUNCATE TABLE new_tt_xx; - } - if ($ddl_cases == 3) - { - let $cmd= DROP TABLE IF EXISTS tt_xx, new_tt_xx; - } - if ($ddl_cases == 2) - { - let $cmd= CREATE DATABASE db; - } - if ($ddl_cases == 1) - { - let $cmd= DROP DATABASE IF EXISTS db; - } - --replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB - --eval $cmd - --disable_query_log - # - # When a temporary table is either created or dropped, there is no implicit - # commit. The flag in_temporary is used to avoid aborting the test in such - # cases. Thus we force the commit. - # - if ($in_temporary == yes) - { - --eval COMMIT - } - let $event_commit= query_get_value("SHOW BINLOG EVENTS FROM $first_binlog_position", Info, $commit_event_row_number); - if (`SELECT SUBSTRING("$event_commit",1,6) != "COMMIT"`) - { - if ($ok == yes) - { - --echo it *does not* commit the current transaction. - --echo $cmd - --echo $event_commit - SHOW BINLOG EVENTS; - exit; - } - } +INSERT INTO tt_1(ddl_case) VALUES (43); +replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB; +eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; +INSERT INTO tt_1(ddl_case) VALUES (42); +DROP FUNCTION myfunc_int; +INSERT INTO tt_1(ddl_case) VALUES (41); +LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; +INSERT INTO tt_1(ddl_case) VALUES (40); +LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; +INSERT INTO tt_1(ddl_case) VALUES (39); +ANALYZE TABLE nt_1; +INSERT INTO tt_1(ddl_case) VALUES (38); +CHECK TABLE nt_1; +INSERT INTO tt_1(ddl_case) VALUES (37); +OPTIMIZE TABLE nt_1; +INSERT INTO tt_1(ddl_case) VALUES (36); +REPAIR TABLE nt_1; +INSERT INTO tt_1(ddl_case) VALUES (35); +LOCK TABLES tt_1 WRITE; +INSERT INTO tt_1(ddl_case) VALUES (34); +UNLOCK TABLES; +INSERT INTO tt_1(ddl_case) VALUES (33); +CREATE USER 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (32); +GRANT ALL ON *.* TO 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (31); +SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); +INSERT INTO tt_1(ddl_case) VALUES (30); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (29); +RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (28); +DROP USER 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (27); +CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (26); +ALTER EVENT evt COMMENT 'evt'; +INSERT INTO tt_1(ddl_case) VALUES (25); +DROP EVENT evt; +INSERT INTO tt_1(ddl_case) VALUES (24); +CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (23); +DROP TRIGGER tr; +INSERT INTO tt_1(ddl_case) VALUES (22); +CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; +INSERT INTO tt_1(ddl_case) VALUES (21); +ALTER FUNCTION fc COMMENT 'fc'; +INSERT INTO tt_1(ddl_case) VALUES (20); +DROP FUNCTION fc; +INSERT INTO tt_1(ddl_case) VALUES (19); +CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (18); +ALTER PROCEDURE pc COMMENT 'pc'; +INSERT INTO tt_1(ddl_case) VALUES (17); +DROP PROCEDURE pc; +INSERT INTO tt_1(ddl_case) VALUES (16); +CREATE VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (15); +ALTER VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (14); +DROP VIEW v; +INSERT INTO tt_1(ddl_case) VALUES (13); +CREATE INDEX ix ON tt_1(ddl_case); +INSERT INTO tt_1(ddl_case) VALUES (12); +DROP INDEX ix ON tt_1; +INSERT INTO tt_1(ddl_case) VALUES (11); +CREATE TEMPORARY TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (10); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (9); +ALTER TABLE tt_xx RENAME new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (8); +DROP TEMPORARY TABLE IF EXISTS new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (7); +CREATE TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (6); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (5); +RENAME TABLE tt_xx TO new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (4); +TRUNCATE TABLE new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (3); +DROP TABLE IF EXISTS tt_xx, new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (2); +CREATE DATABASE db; +INSERT INTO tt_1(ddl_case) VALUES (1); +DROP DATABASE IF EXISTS db; + +source include/show_binlog_events.inc; - --echo -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - let $binlog_start= $first_binlog_position; - --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- - --source include/show_binlog_events.inc - --echo -e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --echo - dec $ddl_cases; -} SET AUTOCOMMIT= 1; --echo ################################################################################### diff --git a/mysql-test/include/galera_wait_ready.inc b/mysql-test/include/galera_wait_ready.inc index e20f01fad90dd5052420c91a6252a2a3c40b4d94..a726116f000bc85a961fc7fb2663f66162ea10ff 100644 --- a/mysql-test/include/galera_wait_ready.inc +++ b/mysql-test/include/galera_wait_ready.inc @@ -1,2 +1,32 @@ -let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' AND VARIABLE_VALUE = 'ON'; ---source include/wait_condition.inc +# include/galera_wait_ready.inc +# +# Waits for galera node to transition to READY state. +# + +--enable_reconnect +--disable_query_log +--disable_result_log +let $wait_counter = 600; +while ($wait_counter) +{ + --disable_abort_on_error + let $success = `SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'`; + --enable_abort_on_error + if ($success) + { + let $wait_counter = 0; + } + if (!$success) + { + real_sleep 0.1; + dec $wait_counter; + } +} + +if (!$success) +{ + die "Server did not transition to READY state"; +} +--disable_reconnect +--enable_query_log +--enable_result_log diff --git a/mysql-test/include/innodb_row_format.combinations b/mysql-test/include/innodb_row_format.combinations new file mode 100644 index 0000000000000000000000000000000000000000..fb94d61dd423b6f3e6c7849c14952194b8932fa0 --- /dev/null +++ b/mysql-test/include/innodb_row_format.combinations @@ -0,0 +1,8 @@ +[redundant] +innodb_default_row_format=redundant + +[compact] +innodb_default_row_format=compact + +[dynamic] +innodb_default_row_format=dynamic diff --git a/mysql-test/include/innodb_row_format.inc b/mysql-test/include/innodb_row_format.inc new file mode 100644 index 0000000000000000000000000000000000000000..8c6357e57d6d5b88497edae617d410217094a679 --- /dev/null +++ b/mysql-test/include/innodb_row_format.inc @@ -0,0 +1,4 @@ +# The goal of including this file is to enable innodb_default_row_format +# combinations (see include/innodb_row_format.combinations) + +--source include/have_innodb.inc diff --git a/mysql-test/include/maybe_debug.combinations b/mysql-test/include/maybe_debug.combinations new file mode 100644 index 0000000000000000000000000000000000000000..5ee57c0bfd8c06039e91424c5c1216cb4f5e1df5 --- /dev/null +++ b/mysql-test/include/maybe_debug.combinations @@ -0,0 +1,5 @@ +[debug] +--enable-gdb + +[release] +--disable-gdb diff --git a/mysql-test/include/maybe_debug.inc b/mysql-test/include/maybe_debug.inc new file mode 100644 index 0000000000000000000000000000000000000000..2f6c2848f9fd0edb28f8c26a5be22866514a8b54 --- /dev/null +++ b/mysql-test/include/maybe_debug.inc @@ -0,0 +1,3 @@ +# include file for test files that can be run with and without debug +# having debug and non-debug tests. +let $have_debug=`select version() like '%debug%'`; diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index a0447280ff564c4697ce339514e2c2e67ec2b4cc..940e081c431653c05f9db7391dcc5e2ce763ab3c 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -50,9 +50,6 @@ if (!$restart_parameters) # Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc -# Wait for wsrep ---source include/wait_wsrep_ready.inc - # Turn off reconnect again --disable_reconnect diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc index 04dff714d497b09afca8ae2f0fa3d68ee9a5cc06..e31f26aad8c85b9323eeccdff125e02c0f6a3b84 100644 --- a/mysql-test/include/start_mysqld.inc +++ b/mysql-test/include/start_mysqld.inc @@ -16,9 +16,6 @@ if (!$restart_parameters) # Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc -# Wait for wsrep ---source include/wait_wsrep_ready.inc - # Turn off reconnect again --disable_reconnect diff --git a/mysql-test/include/wait_condition.inc b/mysql-test/include/wait_condition.inc index 5fbde6950c8be615a5989c2121ec67d8fb63cc04..d40b0e4d448d298c6ed13e4a6b11d321ea110c9b 100644 --- a/mysql-test/include/wait_condition.inc +++ b/mysql-test/include/wait_condition.inc @@ -39,7 +39,7 @@ let $wait_timeout= 0; let $wait_condition_reps= 0; while ($wait_counter) { - --error 0,ER_NO_SUCH_TABLE,ER_LOCK_WAIT_TIMEOUT,ER_UNKNOWN_COM_ERROR + --error 0,ER_NO_SUCH_TABLE,ER_LOCK_WAIT_TIMEOUT,ER_UNKNOWN_COM_ERROR,ER_LOCK_DEADLOCK let $success= `$wait_condition`; inc $wait_condition_reps; if ($success) diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc index 6f64ef454400ef738d944097521f1cf0048b7514..b13d07e94bb026fbbcfc182cfd05f87873347cbe 100644 --- a/mysql-test/include/wait_until_connected_again.inc +++ b/mysql-test/include/wait_until_connected_again.inc @@ -14,7 +14,7 @@ while ($mysql_errno) # Strangely enough, the server might return "Too many connections" # while being shutdown, thus 1040 is an "allowed" error # See BUG#36228 - --error 0,1040,1053,2002,2003,2005,2006,2013,1927 + --error 0,ER_CON_COUNT_ERROR,ER_SERVER_SHUTDOWN,ER_LOCK_WAIT_TIMEOUT,ER_CONNECTION_KILLED,2002,2003,2005,2006,2013 show status; dec $counter; @@ -26,3 +26,9 @@ while ($mysql_errno) } --enable_query_log --enable_result_log + +# WSREP: SHOW STATUS queries are allowed even if wsrep +# is not ready. Make sure wsrep is ready before +# returning from this script + +--source include/wait_wsrep_ready.inc diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm index 1ac0120a73521d45f8d1b3370695fe38e886490a..c5ac2ab51c211f157f6611e2d4b6f2d447674084 100644 --- a/mysql-test/lib/My/SafeProcess/Base.pm +++ b/mysql-test/lib/My/SafeProcess/Base.pm @@ -186,8 +186,10 @@ sub create_process { # it and any childs(that hasn't changed group themself) setpgrp(0,0) if $opts{setpgrp}; - if ( $output and !open(STDOUT, $open_mode, $output) ) { - croak("can't redirect STDOUT to '$output': $!"); + if ( $output ) { + close STDOUT; + open(STDOUT, $open_mode, $output) + or croak "can't redirect STDOUT to '$output': $!"; } if ( $error ) { @@ -196,8 +198,10 @@ sub create_process { croak("can't dup STDOUT: $!"); } } - elsif ( ! open(STDERR, $open_mode, $error) ) { - croak("can't redirect STDERR to '$error': $!"); + else { + close STDERR; + open(STDERR, $open_mode, $error) + or croak "can't redirect STDERR to '$error': $!"; } } diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 8f18b137b871a5524e0b4c9b54c96467c64e9446..f8bed8001145bdcf37614657da009c68bc8c92d7 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -89,7 +89,7 @@ static void die(const char* fmt, ...) } -static void kill_child(bool was_killed) +static int kill_child(bool was_killed) { int status= 0; @@ -108,15 +108,15 @@ static void kill_child(bool was_killed) exit_code= WEXITSTATUS(status); message("Child exit: %d", exit_code); // Exit with exit status of the child - exit(exit_code); + return exit_code; } if (WIFSIGNALED(status)) message("Child killed by signal: %d", WTERMSIG(status)); - exit(exit_code); + return exit_code; } - exit(5); + return 5; } @@ -136,7 +136,7 @@ extern "C" void handle_signal(int sig) terminated= 1; if (child_pid > 0) - kill_child(sig == SIGCHLD); + _exit(kill_child(sig == SIGCHLD)); // Ignore further signals signal(SIGTERM, SIG_IGN); @@ -300,8 +300,6 @@ int main(int argc, char* const argv[] ) /* Wait for parent or child to die */ sleep(1); } - kill_child(0); - - return 4; + return kill_child(0); } diff --git a/mysql-test/lib/My/Tee.pm b/mysql-test/lib/My/Tee.pm new file mode 100644 index 0000000000000000000000000000000000000000..5985fe337395ab44f37fab584b19998166a6b896 --- /dev/null +++ b/mysql-test/lib/My/Tee.pm @@ -0,0 +1,25 @@ +package My::Tee; +use IO::Handle; + +# see PerlIO::via + +our $copyfh; + +sub PUSHED +{ + open($copyfh, '>', "$::opt_vardir/log/stdout.log") + or die "open(>$::opt_vardir/log/stdout.log): $!" + unless $copyfh; + bless { }, shift; +} + +sub WRITE +{ + my ($obj, $buf, $fh) = @_; + print $fh $buf; + $fh->flush; + print $copyfh $buf; + return length($buf); +} + +1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index eaec51b82b45e2408c322a3be8015e27e2a335a4..9df96f636d39f0ef9cf5cf3e98a098252a5e02f6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2,7 +2,7 @@ # -*- cperl -*- # Copyright (c) 2004, 2014, Oracle and/or its affiliates. -# Copyright (c) 2009, 2017, MariaDB Corporation +# Copyright (c) 2009, 2018, 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 @@ -91,6 +91,7 @@ use My::Platform; use My::SafeProcess; use My::ConfigFactory; use My::Options; +use My::Tee; use My::Find; use My::SysInfo; use My::CoreDump; @@ -392,6 +393,11 @@ sub main { initialize_servers(); init_timers(); + unless (IS_WINDOWS) { + binmode(STDOUT,":via(My::Tee)") or die "binmode(STDOUT, :via(My::Tee)):$!"; + binmode(STDERR,":via(My::Tee)") or die "binmode(STDERR, :via(My::Tee)):$!"; + } + mtr_report("Checking supported features..."); executable_setup(); @@ -641,50 +647,59 @@ sub run_test_server ($$$) { my $worker_savename= basename($worker_savedir); my $savedir= "$opt_vardir/log/$worker_savename"; + # Move any core files from e.g. mysqltest + foreach my $coref (glob("core*"), glob("*.dmp")) + { + mtr_report(" - found '$coref', moving it to '$worker_savedir'"); + move($coref, $worker_savedir); + } + + find( + { + no_chdir => 1, + wanted => sub + { + my $core_file= $File::Find::name; + my $core_name= basename($core_file); + + # Name beginning with core, not ending in .gz + if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) + or (IS_WINDOWS and $core_name =~ /\.dmp$/)) + { + # Ending with .dmp + mtr_report(" - found '$core_name'", + "($num_saved_cores/$opt_max_save_core)"); + + My::CoreDump->show($core_file, $exe_mysqld, $opt_parallel); + + # Limit number of core files saved + if ($opt_max_save_core > 0 && + $num_saved_cores >= $opt_max_save_core) + { + mtr_report(" - deleting it, already saved", + "$opt_max_save_core"); + unlink("$core_file"); + } + else + { + mtr_compress_file($core_file) unless @opt_cases; + ++$num_saved_cores; + } + } + } + }, + $worker_savedir); + if ($opt_max_save_datadir > 0 && $num_saved_datadir >= $opt_max_save_datadir) { mtr_report(" - skipping '$worker_savedir/'"); rmtree($worker_savedir); } - else { + else + { mtr_report(" - saving '$worker_savedir/' to '$savedir/'"); rename($worker_savedir, $savedir); - # Move any core files from e.g. mysqltest - foreach my $coref (glob("core*"), glob("*.dmp")) - { - mtr_report(" - found '$coref', moving it to '$savedir'"); - move($coref, $savedir); - } - if ($opt_max_save_core > 0) { - # Limit number of core files saved - find({ no_chdir => 1, - wanted => sub { - my $core_file= $File::Find::name; - my $core_name= basename($core_file); - - # Name beginning with core, not ending in .gz - if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) - or (IS_WINDOWS and $core_name =~ /\.dmp$/)){ - # Ending with .dmp - mtr_report(" - found '$core_name'", - "($num_saved_cores/$opt_max_save_core)"); - - My::CoreDump->show($core_file, $exe_mysqld, $opt_parallel); - - if ($num_saved_cores >= $opt_max_save_core) { - mtr_report(" - deleting it, already saved", - "$opt_max_save_core"); - unlink("$core_file"); - } else { - mtr_compress_file($core_file) unless @opt_cases; - } - ++$num_saved_cores; - } - } - }, - $savedir); - } } resfile_print_test(); $num_saved_datadir++; @@ -4452,6 +4467,7 @@ sub extract_warning_lines ($$) { qr|SSL error: Failed to set ciphers to use|, qr/Plugin 'InnoDB' will be forced to shutdown/, qr|Could not increase number of max_open_files to more than|, + qr|Changed limits: max_open_files|, qr/InnoDB: Error table encrypted but encryption service not available.*/, qr/InnoDB: Could not find a valid tablespace file for*/, qr/InnoDB: Tablespace open failed for*/, @@ -5706,7 +5722,7 @@ sub lldb_arguments { $input = $input ? "< $input" : ""; # write init file for mysqld or client - mtr_tofile($lldb_init_file, "set args $str $input\n"); + mtr_tofile($lldb_init_file, "process launch --stop-at-entry -- $str $input\n"); print "\nTo start lldb for $type, type in another window:\n"; print "cd $glob_mysql_test_dir && lldb -s $lldb_init_file $$exe\n"; @@ -6280,7 +6296,8 @@ sub xterm_stat { my $done = $num_tests - $left; my $spent = time - $^T; - printf "\e];mtr: spent %s on %d tests. %s (%d tests) left\a", + syswrite STDOUT, sprintf + "\e];mtr: spent %s on %d tests. %s (%d tests) left\a", time_format($spent), $done, time_format($spent/$done * $left), $left; } diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 17e2dc9b00975a8927dc6b9d3647424a0bef0500..513bb2eda3191639cab949d2ce46082b85241f3e 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -2174,6 +2174,89 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DROP TABLE t1; # +# MDEV-15308 +# Assertion `ha_alter_info->alter_info->drop_list.elements > 0' failed +# in ha_innodb::prepare_inplace_alter_table +# +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN b; +Warnings: +Note 1091 Can't DROP 'fk'; check that column/key exists +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN b; +Warnings: +Note 1091 Can't DROP 'fk'; check that column/key exists +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, c INT, KEY(c)) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN c; +Warnings: +Note 1091 Can't DROP 'fk'; check that column/key exists +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, c INT, KEY c1(c)) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP INDEX c1; +Warnings: +Note 1091 Can't DROP 'fk'; check that column/key exists +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN IF EXISTS c; +Warnings: +Note 1091 Can't DROP 'fk'; check that column/key exists +Note 1091 Can't DROP 'c'; check that column/key exists +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# MDEV-14668 ADD PRIMARY KEY IF NOT EXISTS on composite key +# +CREATE TABLE t1 ( +`ID` BIGINT(20) NOT NULL, +`RANK` MEDIUMINT(4) NOT NULL, +`CHECK_POINT` BIGINT(20) NOT NULL, +UNIQUE INDEX `HORIZON_UIDX01` (`ID`, `RANK`) +) ENGINE=InnoDB; +ALTER TABLE t1 ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ID` bigint(20) NOT NULL, + `RANK` mediumint(4) NOT NULL, + `CHECK_POINT` bigint(20) NOT NULL, + PRIMARY KEY (`ID`,`CHECK_POINT`), + UNIQUE KEY `HORIZON_UIDX01` (`ID`,`RANK`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); +Warnings: +Note 1061 Multiple primary key defined +DROP TABLE t1; +# # End of 10.0 tests # # diff --git a/mysql-test/r/analyze_stmt_orderby.result b/mysql-test/r/analyze_stmt_orderby.result index be1f01a2a52e34847430470801c5ad9dc3eb80e4..238baff50e13e3f74b032aa522c82b5c4755d14a 100644 --- a/mysql-test/r/analyze_stmt_orderby.result +++ b/mysql-test/r/analyze_stmt_orderby.result @@ -303,7 +303,7 @@ ANALYZE "r_rows": 10, "r_total_time_ms": "REPLACED", "filtered": 100, - "r_filtered": 1, + "r_filtered": 100, "attached_condition": "(t0.a is not null)" } } diff --git a/mysql-test/r/assign_key_cache.result b/mysql-test/r/assign_key_cache.result new file mode 100644 index 0000000000000000000000000000000000000000..4ed6170136b7f302691d710e9b811a382bccb1e4 --- /dev/null +++ b/mysql-test/r/assign_key_cache.result @@ -0,0 +1,13 @@ +set global my_cache.key_buffer_size = 1024*1024; +create table t1 (i int) engine=myisam partition by hash (i) partitions 2; +xa start 'xid'; +cache index t1 partition (non_existing_partition) in my_cache; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache error Error in list of partitions to test.t1 +cache index t1 partition (p1) in my_cache; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +xa end 'xid'; +xa rollback 'xid'; +drop table t1; +set global my_cache.key_buffer_size = 0; diff --git a/mysql-test/r/assign_key_cache-5405.result b/mysql-test/r/assign_key_cache_debug.result similarity index 100% rename from mysql-test/r/assign_key_cache-5405.result rename to mysql-test/r/assign_key_cache_debug.result diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index 315aea0ef4688ef7a7ce39db30bfbdace68577c3..cb66ff483e19839d5168250173e8bb8232045f1c 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -147,7 +147,7 @@ drop table t1; CREATE USER mysqltest_u1@localhost; GRANT USAGE ON *.* TO mysqltest_u1@localhost; -SET GLOBAL max_connections = 3; +SET GLOBAL max_connections = 10; SET GLOBAL event_scheduler = ON; # -- Waiting for Event Scheduler to start... @@ -191,6 +191,13 @@ event_scheduler mysqltest_u1 mysqltest_u1 mysqltest_u1 +mysqltest_u1 +mysqltest_u1 +mysqltest_u1 +mysqltest_u1 +mysqltest_u1 +mysqltest_u1 +mysqltest_u1 root # -- Resetting variables... diff --git a/mysql-test/r/connect_debug.result b/mysql-test/r/connect_debug.result new file mode 100644 index 0000000000000000000000000000000000000000..0452b238db9be1f68fc14fa3e4a7703e818d09e8 --- /dev/null +++ b/mysql-test/r/connect_debug.result @@ -0,0 +1,5 @@ +set @old_dbug=@@global.debug_dbug; +set global debug_dbug='+d,auth_disconnect'; +create user 'bad' identified by 'worse'; +set global debug_dbug=@old_dbug; +drop user bad; diff --git a/mysql-test/r/contributors.result b/mysql-test/r/contributors.result index 927c0bcccbf72cbc68ae25bbea4deb7ac5d9e918..36d033f4cb37401a30768e5c7b0fe2d36b8bfef8 100644 --- a/mysql-test/r/contributors.result +++ b/mysql-test/r/contributors.result @@ -4,13 +4,12 @@ Booking.com https://www.booking.com Founding member, Platinum Sponsor of the Mar Alibaba Cloud https://www.alibabacloud.com/ Platinum Sponsor of the MariaDB Foundation Tencent Cloud https://cloud.tencent.com Platinum Sponsor of the MariaDB Foundation Microsoft https://microsoft.com/ Platinum Sponsor of the MariaDB Foundation -MariaDB Corporation https://mariadb.com Founding member, Gold Sponsor of the MariaDB Foundation +MariaDB Corporation https://mariadb.com Founding member, Platinum Sponsor of the MariaDB Foundation Visma https://visma.com Gold Sponsor of the MariaDB Foundation DBS https://dbs.com Gold Sponsor of the MariaDB Foundation IBM https://www.ibm.com Gold Sponsor of the MariaDB Foundation Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation -Auttomattic https://automattic.com Bronze Sponsor of the MariaDB Foundation Verkkokauppa.com https://www.verkkokauppa.com Bronze Sponsor of the MariaDB Foundation Virtuozzo https://virtuozzo.com Bronze Sponsor of the MariaDB Foundation Tencent Game DBA http://tencentdba.com/about Bronze Sponsor of the MariaDB Foundation diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result index 70b4b98b89cd36299ce8c02f093aec3d9b225098..27aafa976a4fd822fe31dd5af30506955f4e21cf 100644 --- a/mysql-test/r/create_or_replace.result +++ b/mysql-test/r/create_or_replace.result @@ -451,3 +451,23 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1(); UNLOCK TABLES; DROP FUNCTION f1; DROP TABLE t1; +# +# MDEV-11129 +# CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() +# references t1 +# +CREATE OR REPLACE TABLE t1(a INT); +CREATE FUNCTION f1() RETURNS VARCHAR(16383) +BEGIN +INSERT INTO t1 VALUES(1); +RETURN 'test'; +END; +$$ +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +ERROR HY000: Table 't1' is specified twice, both as a target for 'CREATE' and as a separate source for data +LOCK TABLE t1 WRITE; +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +ERROR HY000: Table 't1' was not locked with LOCK TABLES +UNLOCK TABLES; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 85035982cf9ba92a8576479773171a0d35422648..66c5a37750d0b57608060301f985ad8e30112e6f 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -8208,5 +8208,18 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((coalesce(`test`.`t1`.`c`,0) = '3 ') and (coalesce(`test`.`t1`.`d`,0) = '3 ')) DROP TABLE t1; # +# MDEV-15005 ASAN: stack-buffer-overflow in my_strnncollsp_simple +# +SET NAMES latin1; +SELECT CONVERT(1, CHAR) IN ('100', 10, '101'); +CONVERT(1, CHAR) IN ('100', 10, '101') +0 +SELECT CONVERT(1, CHAR) IN ('100', 10, '1'); +CONVERT(1, CHAR) IN ('100', 10, '1') +1 +SELECT CONVERT(1, CHAR) IN ('100', '10', '1'); +CONVERT(1, CHAR) IN ('100', '10', '1') +1 +# # End of 10.1 tests # diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index f9f0acf726fdb2db34bcfa9e46d51e7117a86eaf..55caabbaa12754e0f3574191684ba82ea66c4f38 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -4616,6 +4616,37 @@ Field Type Null Key Default Extra c1 mediumtext YES NULL DROP TABLE t1; # +# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way +# +SET NAMES utf8; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +COUNT(DISTINCT c) +3 +SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; +c +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +COUNT(DISTINCT c) +3 +SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; +c +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +COUNT(DISTINCT c) +3 +SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; +c +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxx +DROP TABLE t1; +# # End of 5.5 tests # # diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 5a77ea3aea5a7eb263da69403bbb51bb59e09f90..3da74d128772aa27fe1423d492556efaae13f734 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -10535,5 +10535,18 @@ CAST(_utf8 0xC499 AS CHAR CHARACTER SET latin1) Warnings: Warning 1977 Cannot convert 'utf8' character 0xC499 to 'latin1' # +# MDEV-15005 ASAN: stack-buffer-overflow in my_strnncollsp_simple +# +SET NAMES utf8; +SELECT CONVERT(1, CHAR) IN ('100', 10, '101'); +CONVERT(1, CHAR) IN ('100', 10, '101') +0 +SELECT CONVERT(1, CHAR) IN ('100', 10, '1'); +CONVERT(1, CHAR) IN ('100', 10, '1') +1 +SELECT CONVERT(1, CHAR) IN ('100', '10', '1'); +CONVERT(1, CHAR) IN ('100', '10', '1') +1 +# # End of 10.1 tests # diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index d45b6b23263faee28e0373c77251abbc56daf5d4..904f432af2066e60b8a52db5dcf7f8d82c5ff8ff 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2859,6 +2859,29 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; len 196608 # +# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way +# +SET NAMES utf8mb4; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(UUID(), "-", "") AS c FROM t1) AS d1; +COUNT(DISTINCT c) +3 +SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1; +c +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1; +COUNT(DISTINCT c) +3 +SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1; +c +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +DROP TABLE t1; +# # End of 5.5 tests # # diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index 81446da9e14d2c74dbf7e94203c1a497d8dc42ba..fe4ee3f7de2b1f782f32f342272c6c36e5e23792 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -1883,5 +1883,15 @@ SELECT COLUMN_JSON(COLUMN_CREATE('test','First line\nSecond line')) AS json; json {"test":"First line\u000ASecond line"} # +# MDEV-15230: column_json breaks cyrillic in 10.1.31 +# +set names utf8; +create table t1 (b blob); +insert into t1 values (column_create('description',column_create('title','ОпиÑание'))); +select column_json(b) from t1; +column_json(b) +{"description":{"title":"ОпиÑание"}} +drop table t1; +# # end of 10.0 tests # diff --git a/mysql-test/r/fast_prefix_index_fetch_innodb.result b/mysql-test/r/fast_prefix_index_fetch_innodb.result index 92af85f7fdbfb59768e92ddc1d41cb2022dc2c24..c6d96389b08d33c9fb6f22c25335fc6de7398d0e 100644 --- a/mysql-test/r/fast_prefix_index_fetch_innodb.result +++ b/mysql-test/r/fast_prefix_index_fetch_innodb.result @@ -30,73 +30,372 @@ id fake_id bigfield 33 1033 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 128 1128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz # Baseline sanity check: 0, 0. +select "no-op query"; no-op query no-op query -cluster_lookups_matched -1 -cluster_lookups_avoided_matched -1 +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 # Eligible for optimization. +select id, bigfield from prefixinno where bigfield = repeat('d', 31); id bigfield 31 ddddddddddddddddddddddddddddddd -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided 1 # Eligible for optimization, access via fake_id only. +select id, bigfield from prefixinno where fake_id = 1031; id bigfield 31 ddddddddddddddddddddddddddddddd -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided 1 # Not eligible for optimization, access via fake_id of big row. +select id, bigfield from prefixinno where fake_id = 1033; id bigfield 33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups 1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 # Not eligible for optimization. +select id, bigfield from prefixinno where bigfield = repeat('x', 32); id bigfield 32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups 1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 # Not eligible for optimization. +select id, bigfield from prefixinno where bigfield = repeat('y', 33); id bigfield 33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups 1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 # Eligible, should not increment lookup counter. +select id, bigfield from prefixinno where bigfield = repeat('b', 8); id bigfield 8 bbbbbbbb -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided 1 # Eligible, should not increment lookup counter. +select id, bigfield from prefixinno where bigfield = repeat('c', 24); id bigfield 24 cccccccccccccccccccccccc -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided 1 # Should increment lookup counter. +select id, bigfield from prefixinno where bigfield = repeat('z', 128); id bigfield 128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz -cluster_lookups_matched -1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups 1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 # Disable optimization, confirm we still increment counter. +set global innodb_prefix_index_cluster_optimization = OFF; +select id, bigfield from prefixinno where fake_id = 1033; id bigfield 33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -cluster_lookups_matched +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +drop table prefixinno; +# Multi-byte handling case +set global innodb_prefix_index_cluster_optimization = ON; +SET NAMES utf8mb4; +CREATE TABLE t1( +f1 varchar(10) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_BIN, +INDEX (f1(3)))ENGINE=INNODB; +INSERT INTO t1 VALUES('a'), ('cccc'), ('až'), ('cÄc'), ('ggáµ·g'), ('¢¢'); +INSERT INTO t1 VALUES('தமிழà¯'), ('ðŸ±ðŸŒ‘'), ('🌒'), ('🌑'); +INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢'); +# Eligible - record length is shorter than prefix +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a'; +f1 +a +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%'; +f1 +cccc +cÄc +select @cluster_lookups; +@cluster_lookups +3 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až'; +f1 +až +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழà¯'; +f1 +தமிழ௠+select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggáµ·%'; +f1 +ggáµ·g +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%'; +f1 +😊me +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢'; +f1 +ls¢ +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '¢¢%'; +f1 +¢¢ +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ðŸ±ðŸŒ‘%'; +f1 +ðŸ±ðŸŒ‘ +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%'; +f1 +🌑 +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +2 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%'; +f1 +🌒 +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +2 +DROP TABLE t1; +# Multi-byte with minimum character length > 1 bytes +CREATE TABLE t1( +f1 varchar(10) CHARACTER SET UTF16 COLLATE UTF16_BIN, +INDEX (f1(3)))ENGINE=INNODB; +INSERT INTO t1 VALUES('a'), ('cccc'), ('až'), ('cÄc'), ('ggáµ·g'), ('¢¢'); +INSERT INTO t1 VALUES('தமிழà¯'), ('ðŸ±ðŸŒ‘'), ('🌒'), ('🌑'); +INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢'); +# Eligible - record length is shorter than prefix +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a'; +f1 +a +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%'; +f1 +cccc +cÄc +select @cluster_lookups; +@cluster_lookups +3 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až'; +f1 +až +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழà¯'; +f1 +தமிழ௠+select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggáµ·%'; +f1 +ggáµ·g +select @cluster_lookups; +@cluster_lookups +2 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%'; +f1 +😊me +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Not eligible - record length longer than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢'; +f1 +ls¢ +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX(`f1`) WHERE f1 like '¢¢%'; +f1 +¢¢ +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +# Eligible - record length shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ðŸ±ðŸŒ‘%'; +f1 +ðŸ±ðŸŒ‘ +select @cluster_lookups; +@cluster_lookups +2 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +# Eligible - record length is shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%'; +f1 +🌑 +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +2 +# Eligible - record length is shorter than prefix length +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%'; +f1 +🌒 +select @cluster_lookups; +@cluster_lookups +1 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +1 +DROP TABLE t1; +CREATE TABLE t1( +col1 INT, +col2 BLOB DEFAULT NULL, +INDEX `idx1`(col2(4), col1))ENGINE=INNODB; +INSERT INTO t1 VALUES (2, 'test'), (3, repeat('test1', 2000)); +INSERT INTO t1(col1) VALUES(1); +# Eligible - record length is shorter than prefix length +SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 is NULL; +col1 1 -cluster_lookups_avoided_matched +select @cluster_lookups; +@cluster_lookups +0 +select @cluster_lookups_avoided; +@cluster_lookups_avoided 1 -# make test suite happy by cleaning up our mess +# Not eligible - record length longer than prefix index +SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 like 'test1%'; +col1 +3 +select @cluster_lookups; +@cluster_lookups +2 +select @cluster_lookups_avoided; +@cluster_lookups_avoided +0 +DROP TABLE t1; +set global innodb_prefix_index_cluster_optimization = OFF; diff --git a/mysql-test/r/func_date_add.result b/mysql-test/r/func_date_add.result index e8fbba786a43f4b3440b768940e6194d4ade76f0..0258267b5ec5e6c7e66879d31b236171e6188dd9 100644 --- a/mysql-test/r/func_date_add.result +++ b/mysql-test/r/func_date_add.result @@ -102,3 +102,54 @@ select * from t1 where case a when adddate( '2012-12-12', 7 ) then true end; a drop table t1; End of 5.5 tests +# +# Start of 10.1 tests +# +# +# MDEV-14452 Precision in INTERVAL xxx DAY_MICROSECOND parsed wrong? +# +SELECT +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5' DAY_MICROSECOND) c1, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50' DAY_MICROSECOND) c2, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500' DAY_MICROSECOND) c3, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000' DAY_MICROSECOND) c4, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000' DAY_MICROSECOND) c5, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000' DAY_MICROSECOND) c6, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000' DAY_MICROSECOND) c7, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000' DAY_MICROSECOND) c8, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000' DAY_MICROSECOND) c9, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000' DAY_MICROSECOND) c10, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000' DAY_MICROSECOND) c11, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000' DAY_MICROSECOND) c12, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000' DAY_MICROSECOND) c13, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000' DAY_MICROSECOND) c14, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000000' DAY_MICROSECOND) c15, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000000' DAY_MICROSECOND) c16, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000000' DAY_MICROSECOND) c17, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000000000' DAY_MICROSECOND) c18, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000000000' DAY_MICROSECOND) c19, +DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000000000' DAY_MICROSECOND) c20 +; +c1 1000-01-01 00:00:01.500000 +c2 1000-01-01 00:00:01.500000 +c3 1000-01-01 00:00:01.500000 +c4 1000-01-01 00:00:01.500000 +c5 1000-01-01 00:00:01.500000 +c6 1000-01-01 00:00:01.500000 +c7 1000-01-01 00:00:01.500000 +c8 1000-01-01 00:00:01.500000 +c9 1000-01-01 00:00:01.500000 +c10 1000-01-01 00:00:01.500000 +c11 1000-01-01 00:00:01.500000 +c12 1000-01-01 00:00:01.500000 +c13 1000-01-01 00:00:01.500000 +c14 1000-01-01 00:00:01.500000 +c15 1000-01-01 00:00:01.500000 +c16 1000-01-01 00:00:01.500000 +c17 1000-01-01 00:00:01.500000 +c18 1000-01-01 00:00:01.500000 +c19 1000-01-01 00:00:01.500000 +c20 NULL +# +# End of 10.1 tests +# diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 545d515176d1487adbf9a77a97fad06ba36969f9..1f9aa2127408c505308b7cd4f5c65b62660d12c3 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -578,6 +578,17 @@ SELECT NAME_CONST('a', -(1)) OR 1; NAME_CONST('a', -(1)) OR 1 1 # +# MDEV-15630 uuid() function evaluates at wrong time in query +# +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT COUNT(1), UUID() as uid FROM t1 GROUP BY uid; +COUNT(1) uid +1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +DROP TABLE t1; +# # End of 5.5 tests # # diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 3c84134d450f7267e90a8df64fb4021d510f3917..3d9c9bc15d97661b86c62f45c35403c03e1dbbf1 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -4568,6 +4568,43 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select char(0xdf) AS `CHAR(0xDF)` # +# MDEV-15619 using CONVERT() inside AES_ENCRYPT() in an UPDATE corrupts data +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +session_id varchar(255) DEFAULT NULL, +directory mediumtext, +checksum int(10) DEFAULT NULL, +last_update datetime DEFAULT NULL, +PRIMARY KEY (id), +KEY lastupdate (last_update) +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,'',NULL,38391,'2017-06-24 07:35:28'); +UPDATE t1 SET directory = AES_ENCRYPT(CONVERT('test stringrererejrjerjehrjekhrjkehrjkehrkjehrjkerhkjehrjekrhkjehrkjerhjkehrkjehrkjehrjkehrjkehrjkehrjkerjkehrjkehrjkehrjke rekjhrejrejhrjehgrehjgrhjerjhegrjherejhgrjhegrjehgrjhegrejhrgjehgrjhegrjhegrjhergjhegrjhegrhjegrjerhthkjjkdhjkgdfjkgjkdgdjkfjkhgjkfdhjgjkfdghkjdfghkjfdghfjkdghkdjfghdkjfghfjkdghfkjdghkjfdghfkjdghfkdjghfkjdghfdjkghjkdfhgdfjkghfjkdghfjkdghfjdkghfjkdghkfjdghfkjdghfkjdghkjdfghfjdkghjkfdghkjdfhgjkdfhgjkfdhgkjfdghkfjdhgkjfdgdjkejktjherjthkjrethkjrethjkerthjkerhtjkerhtkjerhtjkerhtjkerhtjkrehtkjerhtkjrehtjkrehtkjrehtkjerhtkjerhtjkrehtkjrehtjkrehtkjrethjkrethkjrehtkjethjkerhtjkrehtjkretkjerhtkjrehtjkerhtjkrehtjrehtkjrekjtrfgdsfgdhjsghjgfdhjsfhjdfgdhjshjdshjfghjdsfgjhsfgjhsdfgjhdsfgjdhsfgsjhfgjhsdfgsdjhfgjdhsfdjshfgdsjhfgjsdhfdjshfgdjhsfgdjshfgjdhsfgjhsdfgjhsdgfjhsdgfjhdsgfjhsgfjhsdgfjhdsgfhjsdehkjthrkjethjkre' USING latin1), '95F5A1F52A554'), last_update= NOW(); +SELECT directory IS NULL FROM t1; +directory IS NULL +0 +DROP TABLE t1; +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +directory mediumtext +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,AES_ENCRYPT(CONVERT(REPEAT('a',800) USING latin1),'95F5A1F52A554')); +SELECT AES_DECRYPT(directory,'95F5A1F52A554') FROM t1; +AES_DECRYPT(directory,'95F5A1F52A554') +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP TABLE t1; +SET @enc=AES_ENCRYPT(REPEAT(_latin1'a',800),'95F5A1F52A554'); +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +directory mediumtext +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,AES_DECRYPT(CONVERT(@enc USING binary),'95F5A1F52A554')); +SELECT * FROM t1; +id directory +1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP TABLE t1; +# # Start of 10.1 tests # # diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 371dffdd3ae40e465b9b3d7cf7d8d357cf3942fc..2180ec2b83c70186dd3ce0ece4c183b535a8948e 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2904,6 +2904,30 @@ NULL Warnings: Warning 1441 Datetime function: datetime field overflow # +# MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime +# +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '1970-01-01'); +SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR); +MAX(NULLIF(i,1)) +NULL +Warnings: +Warning 1441 Datetime function: datetime field overflow +DROP TABLE t1; +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '1970-01-01'); +SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1; +CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) +NULL +Warnings: +Warning 1441 Datetime function: datetime field overflow +DROP TABLE t1; +SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR)); +CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR)) +NULL +Warnings: +Warning 1441 Datetime function: datetime field overflow +# # End of 10.0 tests # # diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 826d1f6c6b256a1f5acb9ed2f40501bd34e0c1cd..38d0136778e113ec10706630d1ea9e8cbae42ac3 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1644,11 +1644,6 @@ drop user mysqluser11@localhost; drop database mysqltest1; End of 5.0 tests set names utf8; -grant select on test.* to юзер_юзер@localhost; -user() -юзер_юзер@localhost -revoke all on test.* from юзер_юзер@localhost; -drop user юзер_юзер@localhost; grant select on test.* to очень_длинный_юзер890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890@localhost; ERROR HY000: String 'очень_длинный_юзер890123456789012345678901234567890123' is too long for user name (should be no longer than 80) set names default; diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index cf58a2dc6f5e9f81775c5af3d1a43246aca4a87f..bdd88e126178cb780b2ffa6b64f8ea8907d60905 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -707,10 +707,9 @@ LOAD INDEX INTO CACHE t3; Table Op Msg_type Msg_text mysqltest_db1.t3 preload_keys status OK # -# RENAME (doesn't work for temporary tables, thus should fail). +# RENAME should work for temporary tables # RENAME TABLE t3 TO t3_1; -ERROR 42000: INSERT, CREATE command denied to user 'mysqltest_u1'@'localhost' for table 't3_1' # # HANDLER OPEN/READ/CLOSE. # diff --git a/mysql-test/r/grant_not_windows.result b/mysql-test/r/grant_not_windows.result new file mode 100644 index 0000000000000000000000000000000000000000..fedfaf984b2bbd3773de768b12fd89956227a487 --- /dev/null +++ b/mysql-test/r/grant_not_windows.result @@ -0,0 +1,8 @@ +set names utf8; +create user юзер_юзер@localhost; +grant select on test.* to юзер_юзер@localhost; +user() +юзер_юзер@localhost +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +set names default; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index f7503597d3212a70aa3e51db8090e8d41597e5ee..3845f11952827098382c9a275a576a3357391de1 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -723,6 +723,20 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1; c1 c2 x x DROP TABLE t1,t2; +# +# MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ +# in WHERE and HAVING, ORDER BY, materialization+semijoin +# +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (3),(8); +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (2),(1); +SELECT a FROM t1 +WHERE 9 IN ( SELECT MIN( a ) FROM t1 ) +HAVING a <> ( SELECT COUNT(*) FROM t2 ) +ORDER BY a; +a +DROP TABLE t1,t2; End of 10.0 tests # # MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in diff --git a/mysql-test/r/implicit_commit.result b/mysql-test/r/implicit_commit.result index 07536ab07193928d159dff14ee339e3bee226239..b0cd0b75e8d4b93025ccf7776e1619a409abc8ab 100644 --- a/mysql-test/r/implicit_commit.result +++ b/mysql-test/r/implicit_commit.result @@ -562,7 +562,7 @@ INSERT INTO db1.trans (a) VALUES (1); cache index t3 in keycache; CALL db1.test_if_commit(); IMPLICIT COMMIT -YES +NO set global keycache.key_buffer_size=0; # # SQLCOM_PRELOAD_KEYS @@ -571,7 +571,7 @@ INSERT INTO db1.trans (a) VALUES (1); load index into cache t3; CALL db1.test_if_commit(); IMPLICIT COMMIT -YES +NO # # SQLCOM_FLUSH # diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 2b5a536308a716a8852d295b38f9246b3d2095f7..631dd8eabf57e0257b0e0c256c61896904ab4f3c 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1413,7 +1413,7 @@ USE test; End of 5.0 tests. select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -MyISAM DEFAULT MyISAM storage engine NO NO NO +MyISAM DEFAULT Non-transactional engine with good performance and small data footprint NO NO NO grant select on *.* to user3148@localhost; select user,db from information_schema.processlist; user db diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 3f4a26a728ea12fbfa4432f8e4abaa6b8935f6d6..d130854ec1354f852db03a0cdac72df7b2637167 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -854,3 +854,12 @@ INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7; SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size; DROP TABLE t1; End of 5.1 tests +create table t1 (i int); +create table t2 as select values(i) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` binary(0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +End of 5.5 tests diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 78cdfe6ecb15e4e3143984c8aa90e791f2ddd7b0..312b36c16caa2a3483729982ca052d8e2432a760 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2440,11 +2440,27 @@ CREATE TABLE t1 (b1 BIT NOT NULL); INSERT INTO t1 VALUES (0),(1); CREATE TABLE t2 (b2 BIT NOT NULL); INSERT INTO t2 VALUES (0),(1); -SET SESSION JOIN_CACHE_LEVEL = 3; +set @save_join_cache_level= @@join_cache_level; +SET @@join_cache_level = 3; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; t1.b1+'0' t2.b2 + '0' 0 0 1 1 DROP TABLE t1, t2; +set @join_cache_level= @save_join_cache_level; +# +# MDEV-14779: using left join causes incorrect results with materialization and derived tables +# +create table t1(id int); +insert into t1 values (1),(2); +create table t2(sid int, id int); +insert into t2 values (1,1),(2,2); +select * from t1 t +left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r +on t.id=r.id ; +id sid id +1 NULL NULL +2 NULL NULL +drop table t1, t2; # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 861b224043c414bd99bbbd39a66f4f0107da11b7..a006bafcfc0ed8825d38838c5d76e69d5152f4b0 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2451,12 +2451,28 @@ CREATE TABLE t1 (b1 BIT NOT NULL); INSERT INTO t1 VALUES (0),(1); CREATE TABLE t2 (b2 BIT NOT NULL); INSERT INTO t2 VALUES (0),(1); -SET SESSION JOIN_CACHE_LEVEL = 3; +set @save_join_cache_level= @@join_cache_level; +SET @@join_cache_level = 3; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; t1.b1+'0' t2.b2 + '0' 0 0 1 1 DROP TABLE t1, t2; +set @join_cache_level= @save_join_cache_level; +# +# MDEV-14779: using left join causes incorrect results with materialization and derived tables +# +create table t1(id int); +insert into t1 values (1),(2); +create table t2(sid int, id int); +insert into t2 values (1,1),(2,2); +select * from t1 t +left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r +on t.id=r.id ; +id sid id +1 NULL NULL +2 NULL NULL +drop table t1, t2; # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result index 176a93c7a460509ed4ba9cebe95f999937785555..228c1be7a83a49bc4dcc0ab8cf23931539b3b93f 100644 --- a/mysql-test/r/limit.result +++ b/mysql-test/r/limit.result @@ -146,3 +146,19 @@ a 16 DROP TABLE t1; End of 5.1 tests +# +# mdev-16235: SELECT over a table with LIMIT 0 +# +EXPLAIN +SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit +SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0; +start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected +EXPLAIN +SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit +SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0; +help_topic_id name help_category_id description example url +End of 5.5 tests diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 501c379b2578454dad876297711a493774b4c87b..0dcc0de828f4e174e5a8dd93606cabce48785d59 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -407,7 +407,7 @@ LOCK TABLE t1 WRITE; HANDLER t1 OPEN; ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction HANDLER t1 READ FIRST; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +Got one of the listed errors HANDLER t1 CLOSE; ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction UNLOCK TABLES; diff --git a/mysql-test/r/mdev375.result b/mysql-test/r/mdev375.result index 325808046867f80cde09f1381739ecda142bda1a..b3b83af09884e7999967430e650846e882111b07 100644 --- a/mysql-test/r/mdev375.result +++ b/mysql-test/r/mdev375.result @@ -1,5 +1,5 @@ SET GLOBAL log_warnings=4; -SET GLOBAL max_connections=2; +SET GLOBAL max_connections=10; SELECT 1; 1 1 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e114f424ede82d67bd03eab9bf7c8891066cca77..999f489457fc2ab8bf82e973af2481809586d9b4 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1906,16 +1906,17 @@ DROP TABLE t1; # # BUG#48438 - crash with error in unioned query against merge table and view... # -SET GLOBAL table_open_cache=3; +SET @save_table_open_cache=@@table_open_cache; +SET GLOBAL table_open_cache=10; CREATE TABLE t1(a INT); -SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE; +SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4, t1 AS a5, t1 AS a6, t1 AS a7, t1 AS a8, t1 AS a9, t1 AS a10, t1 AS a11 FOR UPDATE; 1 SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; TABLE_ROWS DATA_LENGTH 0 0 DROP TABLE t1; -SET GLOBAL table_open_cache=DEFAULT; +SET GLOBAL table_open_cache=@save_table_open_cache; End of 5.0 tests create table t1 (a int not null, key `a` (a) key_block_size=1024); show create table t1; @@ -2545,6 +2546,14 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; +CREATE TABLE t1(a INT, b CHAR(10), KEY(a), KEY(b)) engine=myisam; +INSERT INTO t1 VALUES(1,'0'),(2,'0'),(3,'0'),(4,'0'),(5,'0'), +(6,'0'),(7,'0'); +flush tables test.t1 for export; +insert into t1 values (8,'0'); +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +drop table t1; show variables like 'myisam_block_size'; Variable_name Value myisam_block_size 1024 diff --git a/mysql-test/r/myisam_recover.result b/mysql-test/r/myisam_recover.result index 0829c1e8b82da7443fc47e1b548c8f4e94b88359..6ae282cb2b60b7073979aa2b780c4ad412013c5c 100644 --- a/mysql-test/r/myisam_recover.result +++ b/mysql-test/r/myisam_recover.result @@ -18,6 +18,7 @@ call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:"); call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); +set @save_table_open_cache=@@table_open_cache; set global table_open_cache=256; set global table_definition_cache=400; drop procedure if exists p_create; @@ -102,7 +103,7 @@ prepare stmt from @drop_table_stmt; execute stmt; deallocate prepare stmt; set @@global.table_definition_cache=default; -set @@global.table_open_cache=default; +set @@global.table_open_cache=@save_table_open_cache; # # 18075170 - sql node restart required to avoid deadlock after # restore diff --git a/mysql-test/r/mysqld--help,win.rdiff b/mysql-test/r/mysqld--help,win.rdiff index 06116a2e630a2858d41002b530d350d9eb5bf7f0..6e18d16feaf3aed0afdaffff2a99ab5b30c6721b 100644 --- a/mysql-test/r/mysqld--help,win.rdiff +++ b/mysql-test/r/mysqld--help,win.rdiff @@ -121,10 +121,10 @@ sync-relay-log 10000 sync-relay-log-info 10000 sysdate-is-now FALSE --table-cache 431 +-table-cache 421 +table-cache 2000 table-definition-cache 400 --table-open-cache 431 +-table-open-cache 421 +table-open-cache 2000 tc-heuristic-recover OFF thread-cache-size 0 diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index e84921bfa0ab0f727d23da4326bcb457edfb56cc..fdb4d8c280df3221691858205e681272f11c0173 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -2,8 +2,10 @@ Windows bug: happens when a new line is exactly at the right offset. The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file. +The following specify which files/extra groups are read (specified before remaining options): --defaults-file=# Only read default options from the given file #. --defaults-extra-file=# Read this file after the global files are read. +--defaults-group-suffix=# Additionally read default groups with # appended as a suffix. --allow-suspicious-udfs Allows use of UDFs consisting of only one symbol xxx() @@ -1438,9 +1440,9 @@ sync-master-info 10000 sync-relay-log 10000 sync-relay-log-info 10000 sysdate-is-now FALSE -table-cache 431 +table-cache 421 table-definition-cache 400 -table-open-cache 431 +table-open-cache 421 tc-heuristic-recover OFF thread-cache-size 0 thread-pool-idle-timeout 60 diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index a5fe01d63c376878630e6c4ad145fd12ef3f9433..48e77421bf40552174725928d7fd0526f2f43ef1 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -5579,3 +5579,18 @@ USE `db1`; DROP DATABASE db1; DROP DATABASE db2; FOUND /Database: mysql/ in bug11505.sql +# +# MDEV-15021: Fix the order in which routines are called +# +use test; +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v1 AS SELECT f(); +# Running mysqldump -uroot test --routines --tables v1 > **vardir**/test.dmp +DROP VIEW v1; +DROP FUNCTION f; +# Running mysql -uroot test < **vardir**/test.dmp +# +# Cleanup after succesful import. +# +DROP VIEW v1; +DROP FUNCTION f; diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index d3c5107dee330aa2528fd5a31b315335435801d8..791cb5ac6b38d42eb12096d957e7040e7e5de687 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -255,3 +255,6 @@ Benchmark # MDEV-4684 - Enhancement request: --init-command support for mysqlslap # DROP TABLE t1; +# +# Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK +# diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index b10f175b63e65a01cfe84d8e471c9ae618eb79df..24140583d13e83832752e6a0477cf747f5c9a128 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -766,3 +766,25 @@ b NULL DROP TABLE t1, t2; End of 5.0 tests +# +# Start of 10.1 tests +# +# +# MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with time field, ROLLUP and HAVING +# +CREATE TABLE t1 (t TIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('12:12:12'); +SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00'; +t COUNT(*) +12:12:12 1 +DROP TABLE t1; +CREATE TABLE t1 (t TIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('12:12:12'),('12:12:13'); +SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00'; +t COUNT(*) +12:12:12 1 +12:12:13 1 +DROP TABLE t1; +# +# End of 10.1 tests +# diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 26f4b018726bd21e0c952a012247a512ad94f98b..3ebd84ff521ebd00eac11223640af4c5d53a5a7b 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -673,6 +673,13 @@ PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\ ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\' at line 1 DROP TABLE t1; # +# MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger +# +CREATE TABLE t1 (a INT); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @@NEW.a=0; +ERROR HY000: Unknown system variable 'NEW' +DROP TABLE t1; +# # MDEV-7792 - SQL Parsing Error - UNION AND ORDER BY WITH JOIN # CREATE TABLE t1(a INT); diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result index 432a4fd4c04bc4ffa78351c48df70f7616de9a3c..46554442721075d7f1764fffa337cafa52f4daad 100644 --- a/mysql-test/r/perror.result +++ b/mysql-test/r/perror.result @@ -3,4 +3,4 @@ MySQL error code 1062 (ER_DUP_ENTRY): Duplicate entry '%-.192s' for key %d MySQL error code 1408 (ER_STARTUP): %s: ready for connections. Version: '%s' socket: '%s' port: %d %s MySQL error code 1459 (ER_TABLE_NEEDS_UPGRADE): Upgrade required. Please do "REPAIR %s %`s" or dump/reload to fix it! -MySQL error code 1461 (ER_MAX_PREPARED_STMT_COUNT_REACHED): Can't create more than max_prepared_stmt_count statements (current value: %lu) +MySQL error code 1461 (ER_MAX_PREPARED_STMT_COUNT_REACHED): Can't create more than max_prepared_stmt_count statements (current value: %u) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 26e7bc3736363718aec652e7f6cb3bf74341f59f..1b40a7342630ad258774139239f8689e4bab8b5f 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -821,7 +821,7 @@ Warnings: Warning 1292 Truncated incorrect max_prepared_stmt_count value: '10000000000000000' select @@max_prepared_stmt_count; @@max_prepared_stmt_count -1048576 +4294967295 set global max_prepared_stmt_count=default; select @@max_prepared_stmt_count; @@max_prepared_stmt_count @@ -4351,3 +4351,45 @@ LINE2 2 LINE3 3 drop table t1; # End of 5.5 tests +# +# Start of 10.1 tests +# +# +# MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command +# (the 10.1 part) +# +CREATE PROCEDURE p2 () +BEGIN +SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +END; +/ +CALL p2(); +1 +1 +DROP PROCEDURE p2; +BEGIN NOT ATOMIC +SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +END; +/ +1 +1 +BEGIN NOT ATOMIC +SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; +DEALLOCATE PREPARE stmt; +END; +/ +BEGIN NOT ATOMIC +PREPARE stmt FROM 'SELECT 1'; +SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR EXECUTE stmt; +DEALLOCATE PREPARE stmt; +END; +/ +1 +1 +# +# End of 10.1 tests +# diff --git a/mysql-test/r/ps_qc_innodb.result b/mysql-test/r/ps_qc_innodb.result new file mode 100644 index 0000000000000000000000000000000000000000..775055e858f1d8f5811290db36eb16234eca00df --- /dev/null +++ b/mysql-test/r/ps_qc_innodb.result @@ -0,0 +1,23 @@ +# +# MDEV-15492: Subquery crash similar to MDEV-10050 +# +SET @qcs.save= @@global.query_cache_size, @qct.save= @@global.query_cache_type; +SET GLOBAL query_cache_size= 512*1024*1024, query_cache_type= ON; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (b INT) ENGINE=InnoDB; +CREATE VIEW v AS select a from t1 join t2; +PREPARE stmt1 FROM "SELECT * FROM t1 WHERE a in (SELECT a FROM v)"; +PREPARE stmt2 FROM "SELECT * FROM t1 WHERE a in (SELECT a FROM v)"; +EXECUTE stmt2; +a +EXECUTE stmt1; +a +INSERT INTO t2 VALUES (0); +EXECUTE stmt1; +a +START TRANSACTION; +EXECUTE stmt1; +a +DROP VIEW v; +DROP TABLE t1, t2; +SET GLOBAL query_cache_size= @qcs.save, query_cache_type= @qct.save; diff --git a/mysql-test/r/rename.result b/mysql-test/r/rename.result index 74370ba74ddb1beae6163b5ef20d631a638f8a06..c90aaf24e9bcc64b4bd50357b56710d49f7b13b4 100644 --- a/mysql-test/r/rename.result +++ b/mysql-test/r/rename.result @@ -67,3 +67,69 @@ ERROR HY000: 'test.v1' is not BASE TABLE drop view v1; drop table t1; End of 5.0 tests +CREATE OR REPLACE TABLE t1 (a INT); +CREATE OR REPLACE TABLE t2 (a INT); +CREATE OR REPLACE TEMPORARY TABLE t1_tmp (b INT); +CREATE OR REPLACE TEMPORARY TABLE t2_tmp (b INT); +rename table t1 to t2; +ERROR 42S01: Table 't2' already exists +rename table t1 to tmp, tmp to t2; +ERROR 42S01: Table 't2' already exists +rename table t1_tmp to t2_tmp; +ERROR 42S01: Table 't2_tmp' already exists +rename table t1_tmp to tmp, tmp to t2_tmp; +ERROR 42S01: Table 't2_tmp' already exists +show create table t1_tmp; +Table Create Table +t1_tmp CREATE TEMPORARY TABLE `t1_tmp` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t2_tmp; +Table Create Table +t2_tmp CREATE TEMPORARY TABLE `t2_tmp` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +rename table t1 to t1_tmp; +rename table t2_tmp to t2; +rename table t2 to tmp, tmp to t2; +rename table t1_tmp to tmp, tmp to t1_tmp; +show tables; +Tables_in_test +t1_tmp +t2 +SHOW CREATE TABLE t1_tmp; +Table Create Table +t1_tmp CREATE TEMPORARY TABLE `t1_tmp` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1_tmp; +SHOW CREATE TABLE t1_tmp; +Table Create Table +t1_tmp CREATE TABLE `t1_tmp` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1_tmp; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2; +CREATE TABLE t1 (a INT); +insert into t1 values (1); +CREATE TEMPORARY TABLE t1 (b INT); +insert into t1 values (2); +RENAME TABLE t1 TO tmp, t1 TO t2; +select * from tmp; +b +2 +select * from t2; +a +1 +drop table tmp,t2; diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result index 01847006928c28123efdddb8bc70e8cb8f8cc5a1..6cb7934678b01acaecb9c4d6cd46e244bd7f3329 100644 --- a/mysql-test/r/selectivity.result +++ b/mysql-test/r/selectivity.result @@ -356,13 +356,13 @@ and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 6005 0.00 Using temporary; Using filesort -1 PRIMARY orders eq_ref PRIMARY,i_o_custkey PRIMARY 4 .l_orderkey 1 100.00 Using where +1 PRIMARY orders ALL PRIMARY,i_o_custkey NULL NULL NULL 1500 100.00 Using where; Using temporary; Using filesort +1 PRIMARY eq_ref distinct_key distinct_key 4 dbt3_s001.orders.o_orderkey 1 100.00 1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey 1 100.00 -1 PRIMARY lineitem ref PRIMARY,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 .l_orderkey 4 100.00 +1 PRIMARY lineitem ref PRIMARY,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey_quantity 4 dbt3_s001.orders.o_orderkey 4 100.00 Using index 2 MATERIALIZED lineitem index NULL i_l_orderkey_quantity 13 NULL 6005 100.00 Using index Warnings: -Note 1003 select `dbt3_s001`.`customer`.`c_name` AS `c_name`,`dbt3_s001`.`customer`.`c_custkey` AS `c_custkey`,`dbt3_s001`.`orders`.`o_orderkey` AS `o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE` AS `o_orderdate`,`dbt3_s001`.`orders`.`o_totalprice` AS `o_totalprice`,sum(`dbt3_s001`.`lineitem`.`l_quantity`) AS `sum(l_quantity)` from (select `dbt3_s001`.`lineitem`.`l_orderkey` from `dbt3_s001`.`lineitem` group by `dbt3_s001`.`lineitem`.`l_orderkey` having (sum(`dbt3_s001`.`lineitem`.`l_quantity`) > 250)) join `dbt3_s001`.`customer` join `dbt3_s001`.`orders` join `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`customer`.`c_custkey` = `dbt3_s001`.`orders`.`o_custkey`) and (`dbt3_s001`.`orders`.`o_orderkey` = ``.`l_orderkey`) and (`dbt3_s001`.`lineitem`.`l_orderkey` = ``.`l_orderkey`)) group by `dbt3_s001`.`customer`.`c_name`,`dbt3_s001`.`customer`.`c_custkey`,`dbt3_s001`.`orders`.`o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE`,`dbt3_s001`.`orders`.`o_totalprice` order by `dbt3_s001`.`orders`.`o_totalprice` desc,`dbt3_s001`.`orders`.`o_orderDATE` +Note 1003 select `dbt3_s001`.`customer`.`c_name` AS `c_name`,`dbt3_s001`.`customer`.`c_custkey` AS `c_custkey`,`dbt3_s001`.`orders`.`o_orderkey` AS `o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE` AS `o_orderdate`,`dbt3_s001`.`orders`.`o_totalprice` AS `o_totalprice`,sum(`dbt3_s001`.`lineitem`.`l_quantity`) AS `sum(l_quantity)` from (select `dbt3_s001`.`lineitem`.`l_orderkey` from `dbt3_s001`.`lineitem` group by `dbt3_s001`.`lineitem`.`l_orderkey` having (sum(`dbt3_s001`.`lineitem`.`l_quantity`) > 250)) join `dbt3_s001`.`customer` join `dbt3_s001`.`orders` join `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`customer`.`c_custkey` = `dbt3_s001`.`orders`.`o_custkey`) and (``.`l_orderkey` = `dbt3_s001`.`orders`.`o_orderkey`) and (`dbt3_s001`.`lineitem`.`l_orderkey` = `dbt3_s001`.`orders`.`o_orderkey`)) group by `dbt3_s001`.`customer`.`c_name`,`dbt3_s001`.`customer`.`c_custkey`,`dbt3_s001`.`orders`.`o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE`,`dbt3_s001`.`orders`.`o_totalprice` order by `dbt3_s001`.`orders`.`o_totalprice` desc,`dbt3_s001`.`orders`.`o_orderDATE` select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem @@ -1530,6 +1530,68 @@ t 10:00:00 11:00:00 DROP TABLE t1; +# +# MDEV-16374: filtered shows 0 for materilization scan for a semi join, which makes optimizer +# always pick materialization scan over materialization lookup +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int); +insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10), +(11,11),(12,12),(13,13),(14,14),(15,15); +set @@optimizer_use_condition_selectivity=2; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 16 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 16 100.00 Using temporary +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (select max(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`b`) join `test`.`t1` where (``.`max(a)` = `test`.`t1`.`a`) +select * from t1 where a in (select max(a) from t1 group by b); +a b +0 0 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +set @@optimizer_use_condition_selectivity=1; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 16 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 16 100.00 Using temporary +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (select max(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`b`) join `test`.`t1` where (``.`max(a)` = `test`.`t1`.`a`) +select * from t1 where a in (select max(a) from t1 group by b); +a b +0 0 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +drop table t1,t0; set histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result index 070cc49ca7f8ded5a4acd57c6d10a4c582bdfb16..e0227163d692ed5fd08226081f04e443b81eba5d 100644 --- a/mysql-test/r/selectivity_innodb.result +++ b/mysql-test/r/selectivity_innodb.result @@ -359,13 +359,13 @@ and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 6005 0.00 Using temporary; Using filesort -1 PRIMARY orders eq_ref PRIMARY,i_o_custkey PRIMARY 4 .l_orderkey 1 100.00 Using where +1 PRIMARY orders ALL PRIMARY,i_o_custkey NULL NULL NULL 1500 100.00 Using where; Using temporary; Using filesort +1 PRIMARY eq_ref distinct_key distinct_key 4 dbt3_s001.orders.o_orderkey 1 100.00 1 PRIMARY customer eq_ref PRIMARY PRIMARY 4 dbt3_s001.orders.o_custkey 1 100.00 -1 PRIMARY lineitem ref PRIMARY,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 .l_orderkey 4 100.00 +1 PRIMARY lineitem ref PRIMARY,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey_quantity 4 dbt3_s001.orders.o_orderkey 4 100.00 Using index 2 MATERIALIZED lineitem index NULL PRIMARY 8 NULL 6005 100.00 Warnings: -Note 1003 select `dbt3_s001`.`customer`.`c_name` AS `c_name`,`dbt3_s001`.`customer`.`c_custkey` AS `c_custkey`,`dbt3_s001`.`orders`.`o_orderkey` AS `o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE` AS `o_orderdate`,`dbt3_s001`.`orders`.`o_totalprice` AS `o_totalprice`,sum(`dbt3_s001`.`lineitem`.`l_quantity`) AS `sum(l_quantity)` from (select `dbt3_s001`.`lineitem`.`l_orderkey` from `dbt3_s001`.`lineitem` group by `dbt3_s001`.`lineitem`.`l_orderkey` having (sum(`dbt3_s001`.`lineitem`.`l_quantity`) > 250)) join `dbt3_s001`.`customer` join `dbt3_s001`.`orders` join `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`customer`.`c_custkey` = `dbt3_s001`.`orders`.`o_custkey`) and (`dbt3_s001`.`orders`.`o_orderkey` = ``.`l_orderkey`) and (`dbt3_s001`.`lineitem`.`l_orderkey` = ``.`l_orderkey`)) group by `dbt3_s001`.`customer`.`c_name`,`dbt3_s001`.`customer`.`c_custkey`,`dbt3_s001`.`orders`.`o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE`,`dbt3_s001`.`orders`.`o_totalprice` order by `dbt3_s001`.`orders`.`o_totalprice` desc,`dbt3_s001`.`orders`.`o_orderDATE` +Note 1003 select `dbt3_s001`.`customer`.`c_name` AS `c_name`,`dbt3_s001`.`customer`.`c_custkey` AS `c_custkey`,`dbt3_s001`.`orders`.`o_orderkey` AS `o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE` AS `o_orderdate`,`dbt3_s001`.`orders`.`o_totalprice` AS `o_totalprice`,sum(`dbt3_s001`.`lineitem`.`l_quantity`) AS `sum(l_quantity)` from (select `dbt3_s001`.`lineitem`.`l_orderkey` from `dbt3_s001`.`lineitem` group by `dbt3_s001`.`lineitem`.`l_orderkey` having (sum(`dbt3_s001`.`lineitem`.`l_quantity`) > 250)) join `dbt3_s001`.`customer` join `dbt3_s001`.`orders` join `dbt3_s001`.`lineitem` where ((`dbt3_s001`.`customer`.`c_custkey` = `dbt3_s001`.`orders`.`o_custkey`) and (``.`l_orderkey` = `dbt3_s001`.`orders`.`o_orderkey`) and (`dbt3_s001`.`lineitem`.`l_orderkey` = `dbt3_s001`.`orders`.`o_orderkey`)) group by `dbt3_s001`.`customer`.`c_name`,`dbt3_s001`.`customer`.`c_custkey`,`dbt3_s001`.`orders`.`o_orderkey`,`dbt3_s001`.`orders`.`o_orderDATE`,`dbt3_s001`.`orders`.`o_totalprice` order by `dbt3_s001`.`orders`.`o_totalprice` desc,`dbt3_s001`.`orders`.`o_orderDATE` select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem @@ -1540,6 +1540,68 @@ t 10:00:00 11:00:00 DROP TABLE t1; +# +# MDEV-16374: filtered shows 0 for materilization scan for a semi join, which makes optimizer +# always pick materialization scan over materialization lookup +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int); +insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10), +(11,11),(12,12),(13,13),(14,14),(15,15); +set @@optimizer_use_condition_selectivity=2; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 16 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 16 100.00 Using temporary +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (select max(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`b`) join `test`.`t1` where (``.`max(a)` = `test`.`t1`.`a`) +select * from t1 where a in (select max(a) from t1 group by b); +a b +0 0 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +set @@optimizer_use_condition_selectivity=1; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 16 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t1.a 1 100.00 +2 MATERIALIZED t1 ALL NULL NULL NULL NULL 16 100.00 Using temporary +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (select max(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`b`) join `test`.`t1` where (``.`max(a)` = `test`.`t1`.`a`) +select * from t1 where a in (select max(a) from t1 group by b); +a b +0 0 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +drop table t1,t0; set histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result index 0eddfa70dd15d208bba3c4c15f35e2497d409e1e..a3754d25a8a7428707c82beb193403fbdfca80d9 100644 --- a/mysql-test/r/sp-destruct.result +++ b/mysql-test/r/sp-destruct.result @@ -171,3 +171,9 @@ create database mysqltest1; create procedure mysqltest1.foo() select "foo"; update mysql.proc set name='' where db='mysqltest1'; drop database mysqltest1; +create procedure p1() set @foo = 10; +alter table mysql.proc drop primary key; +drop procedure p1; +ERROR HY000: Cannot load from mysql.proc. The table is probably corrupted +alter table mysql.proc add primary key (db,name,type); +drop procedure p1; diff --git a/mysql-test/r/sp-innodb.result b/mysql-test/r/sp-innodb.result index b3405705698dbbe60ca379ac2a7c106d7be71801..8dee74040b3b2950436adee76d59b3e94235d942 100644 --- a/mysql-test/r/sp-innodb.result +++ b/mysql-test/r/sp-innodb.result @@ -130,3 +130,37 @@ SET @@innodb_lock_wait_timeout= @innodb_lock_wait_timeout_saved; # # BUG 16041903: End of test case # +# +# MDEV-15035: SP using query with outer join and a parameter +# in ON expression +# +CREATE TABLE t1 ( +id int NOT NULL, +PRIMARY KEY (id) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 ( +id int NOT NULL, +id_foo int NOT NULL, +PRIMARY KEY (id) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 1); +DROP PROCEDURE IF EXISTS test_proc; +CREATE PROCEDURE test_proc(IN param int) +LANGUAGE SQL +READS SQL DATA +BEGIN +SELECT DISTINCT f.id +FROM t1 f +LEFT OUTER JOIN t2 b ON b.id_foo = f.id +WHERE (param <> 0 OR b.id IS NOT NULL); +END| +CALL test_proc(0); +id +1 +CALL test_proc(1); +id +1 +2 +DROP PROCEDURE IF EXISTS test_proc; +DROP TABLE t1, t2; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 57d704c36be040958ff9aa222ddcc22091f71780..bc33c08d9d8568ff813544c814c7ae7feeb7d102 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7946,7 +7946,7 @@ CLOSE cur1; end| set @tmp_toc= @@table_open_cache; set @tmp_tdc= @@table_definition_cache; -set global table_open_cache=1; +set global table_open_cache=10; set global table_definition_cache=1; Warnings: Warning 1292 Truncated incorrect table_definition_cache value: '1' @@ -8242,4 +8242,15 @@ DROP PROCEDURE proc_13; DROP PROCEDURE proc_select; DROP TABLE t1, t2; SET max_sp_recursion_depth=default; +# +# MDEV-15347: Valgrind or ASAN errors in mysql_make_view on query +# from information_schema +# +CREATE VIEW v AS SELECT 1; +CREATE FUNCTION f() RETURNS INT RETURN 1; +SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS +UNION +SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS; +DROP FUNCTION f; +DROP VIEW v; #End of 10.1 tests diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result index 2d0f18f1ed76cc294b6263dc1a416d96be67a234..d5a112cc7794320533415850e7623156310b6f53 100644 --- a/mysql-test/r/statistics.result +++ b/mysql-test/r/statistics.result @@ -1664,6 +1664,24 @@ db_name table_name column_name HEX(min_value) HEX(max_value) nulls_ratio avg_fre test t1 a D879626AF872675F73E662F8 D879626AF872675F73E662F8 0.0000 1.0000 0 NULL NULL drop table t1; # +# MDEB-9744: session optimizer_use_condition_selectivity=5 causing SQL Error (1918): +# Encountered illegal value '' when converting to DECIMAL +# +set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=3, use_stat_tables=preferably; +create table t1 (id int(10),cost decimal(9,2)) engine=innodb; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +create temporary table t2 (id int); +insert into t2 (id) select id from t1 where cost > 0; +select * from t2; +id +set use_stat_tables=@save_use_stat_tables; +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +drop table t1,t2; +# # MDEV-9590: Always print "Engine-independent statistic" warnings and # might be filtering columns unintentionally from engines # diff --git a/mysql-test/r/statistics_close.result b/mysql-test/r/statistics_close.result new file mode 100644 index 0000000000000000000000000000000000000000..348681c33116c8a1d106b4f0e4c8dead5c23891b --- /dev/null +++ b/mysql-test/r/statistics_close.result @@ -0,0 +1,6 @@ +CREATE TABLE t1 (i int); +RENAME TABLE t1 TO t2; +FLUSH TABLES; +DROP TABLE IF EXISTS t1, t2; +Warnings: +Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 4e70615120f9f524a402a645f311a9f25a013dcb..a7e2bd9d1b5f9dd9603691987aae3ee8306b9dcd 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2489,9 +2489,40 @@ FROM t2 WHERE b <= 'quux' GROUP BY field; field COUNT(DISTINCT c) 0 1 drop table t1,t2; +# +# MDEV-15555: select from DUAL where false yielding wrong result when in a IN +# +explain +SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1); +2 IN (SELECT 2 from DUAL WHERE 1 != 1) +0 SET optimizer_switch= @@global.optimizer_switch; set @@tmp_table_size= @@global.tmp_table_size; # +# MDEV-14515: Wrong results for tableless query with subquery in WHERE +# and implicit aggregation +# +create table t1 (i1 int, i2 int); +insert into t1 values (1314, 1084),(1330, 1084),(1401, 1084),(580, 1084); +create table t2 (cd int); +insert into t2 values +(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330), +(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330); +select max(10) from dual +where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345); +max(10) +NULL +insert into t2 select * from t2; +select max(10) from dual +where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345); +max(10) +NULL +DROP TABLE t1,t2; +# # MDEV-10232 Scalar result of subquery changes after adding an outer select stmt # create table t1(c1 int, c2 int, primary key(c2)); diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index 934aca92f9f37aad311cd69e53e4e0801121133c..924317dbcd19160c200f70f4f3dbff4f8492a91f 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -2757,6 +2757,21 @@ a b sq 4 2 1 drop table t1, t2; # +# MDEV-15235: Assertion `length > 0' failed in create_ref_for_key +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f CHAR(1)); +INSERT INTO t2 VALUES ('a'),('b'); +explain +SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 +SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 ); +f +DROP TABLE t1, t2; +# # MDEV-9489: Assertion `0' failed in Protocol::end_statement() on # UNION ALL # diff --git a/mysql-test/r/subselect_mat_cost_bugs.result b/mysql-test/r/subselect_mat_cost_bugs.result index df6b543bab8d6eed33730aa64672faa73bc1801c..d33f1488e4df4034c58bdda87efc22a792e1113d 100644 --- a/mysql-test/r/subselect_mat_cost_bugs.result +++ b/mysql-test/r/subselect_mat_cost_bugs.result @@ -334,7 +334,7 @@ SELECT * FROM t1 WHERE (f1) IN (SELECT f1 FROM t2) LIMIT 0; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Zero limit 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where SELECT * FROM t1 WHERE (f1) IN (SELECT f1 FROM t2) diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 643034f452d8402c7cd9dae0ec03967c1d168d9d..77dea34e2ab1ebb841f0d15639bef03710d35163 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -3161,4 +3161,30 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`c1`,(select `test`.`t3`.`c3` from `test`.`t3` where ((`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1 DROP TABLE t1,t2,t3,t4; +# +# MDEV-13699: Assertion `!new_field->field_name.str || +# strlen(new_field->field_name.str) == new_field->field_name.length' +# failed in create_tmp_table on 2nd execution of PS with semijoin +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +CREATE TABLE t3 (c INT); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t3 VALUES (5),(6); +PREPARE stmt FROM +"SELECT * FROM t1 + WHERE EXISTS ( + SELECT * FROM t2 WHERE t1.a IN ( SELECT c AS fld FROM v3 ) + )"; +EXECUTE stmt; +a +EXECUTE stmt; +a +EXECUTE stmt; +a +drop view v3; +drop table t1,t2,t3; +# End of 5.5 test set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index c8ee451c62f79e364ffb958b9a9bf22748490b5c..db4ae1714eaa9a1f90e2bed41d7ada369d114027 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1655,3 +1655,60 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY eq_ref distinct_key distinct_key 11 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where DROP TABLE t1,t2; +# +# MDEV-16225: wrong resultset from query with semijoin=on +# +CREATE TABLE t1 ( +`id` int(10) NOT NULL AUTO_INCREMENT, +`local_name` varchar(64) NOT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1; +insert into t1(`id`,`local_name`) values +(1,'Cash Advance'), +(2,'Cash Advance'), +(3,'Rollover'), +(4,'AL Installment'), +(5,'AL Installment'), +(6,'AL Installment'), +(7,'AL Installment'), +(8,'AL Installment'), +(9,'AL Installment'), +(10,'Internet Payday'), +(11,'Rollover - Internet Payday'), +(12,'AL Monthly Installment'), +(13,'AL Semi-Monthly Installment'); +explain +SELECT SQL_NO_CACHE t.id +FROM t1 t +WHERE ( +t.id IN (SELECT A.id FROM t1 AS A WHERE A.local_name IN (SELECT B.local_name FROM t1 AS B WHERE B.id IN (0,4,12,13,1,10,3,11))) +OR +(t.id IN (0,4,12,13,1,10,3,11)) +); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t index PRIMARY PRIMARY 4 NULL 13 Using where; Using index +2 MATERIALIZED ALL distinct_key NULL NULL NULL 8 +2 MATERIALIZED A ALL PRIMARY NULL NULL NULL 13 Using where; Using join buffer (flat, BNL join) +3 MATERIALIZED B ALL PRIMARY NULL NULL NULL 13 Using where +SELECT SQL_NO_CACHE t.id +FROM t1 t +WHERE ( +t.id IN (SELECT A.id FROM t1 AS A WHERE A.local_name IN (SELECT B.local_name FROM t1 AS B WHERE B.id IN (0,4,12,13,1,10,3,11))) +OR +(t.id IN (0,4,12,13,1,10,3,11)) +); +id +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +drop table t1; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 6d9dc37345aac97bda578d4acc823a5947a81c11..0741eb236ea8d60269bda50e866751f1cac31f53 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -3175,6 +3175,32 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`c1`,(select `test`.`t3`.`c3` from `test`.`t3` where ((`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1 DROP TABLE t1,t2,t3,t4; +# +# MDEV-13699: Assertion `!new_field->field_name.str || +# strlen(new_field->field_name.str) == new_field->field_name.length' +# failed in create_tmp_table on 2nd execution of PS with semijoin +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +CREATE TABLE t3 (c INT); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t3 VALUES (5),(6); +PREPARE stmt FROM +"SELECT * FROM t1 + WHERE EXISTS ( + SELECT * FROM t2 WHERE t1.a IN ( SELECT c AS fld FROM v3 ) + )"; +EXECUTE stmt; +a +EXECUTE stmt; +a +EXECUTE stmt; +a +drop view v3; +drop table t1,t2,t3; +# End of 5.5 test set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/r/subselect_sj_nonmerged.result b/mysql-test/r/subselect_sj_nonmerged.result index c7e04225ffea4ac7988f1265c7da4e6319c5246a..47970668ae578a84c2390a9d93617fd2e8b9a72d 100644 --- a/mysql-test/r/subselect_sj_nonmerged.result +++ b/mysql-test/r/subselect_sj_nonmerged.result @@ -77,9 +77,9 @@ explain select * from t4 where t4.a in (select max(t2.a) from t1, t2 group by t2.b) and t4.b in (select max(t2.a) from t1, t2 group by t2.b); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL distinct_key NULL NULL NULL 5 -1 PRIMARY ALL distinct_key NULL NULL NULL 5 Using join buffer (flat, BNL join) -1 PRIMARY t4 ref a a 10 .max(t2.a),.max(t2.a) 12 +1 PRIMARY ALL distinct_key NULL NULL NULL 5 +1 PRIMARY t4 ref a a 5 .max(t2.a) 12 Using index condition +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t4.b 1 3 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using temporary 3 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using temporary diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 8455450e29427878f61184d6df5494e2b96b068f..8852a62225191c380130da8ac2b833a3d7901224 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2306,4 +2306,15 @@ CREATE TABLE t1 (i INT); insert into t2 value (2); DROP VIEW v1; DROP TABLE t1,t2,t3; -End of 10.1 tests. +# +# MDEV-16093 +# Assertion `global_status_var.global_memory_used == 0' failed or +# bytes lost after inserting into table with non-null blob and trigger +# +CREATE TABLE t1 (b BLOB NOT NULL); +CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END; +INSERT INTO t1 VALUES ('foo'); +DROP TABLE t1; +# +# End of 10.1 tests. +# diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index b5689d31aef60628e582c8072064c807074772d1..fc287e86fbd0845f520a3fa6a06fd05e8e3937e8 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -1215,5 +1215,36 @@ MAX(a) MAX(COALESCE(a)) 10:20:30 10:20:30 DROP TABLE t1; # +# MDEV-15321: different results when using value of optimizer_use_condition_selectivity=4 and =1 +# +SET @save_old_mode=@@old_mode; +SET @@old_mode=zero_date_time_cast; +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('0000-00-00 10:20:30'),('0000-00-00 10:20:31'); +INSERT INTO t1 VALUES ('0000-00-01 10:20:30'),('0000-00-01 10:20:31'); +INSERT INTO t1 VALUES ('31 10:20:30'),('32 10:20:30'),('33 10:20:30'),('34 10:20:30'); +SET @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +SET @@optimizer_use_condition_selectivity=1; +SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +a +34:20:30 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = '0000-00-01 10:20:30') and (length(`test`.`t1`.`a`) = 8)) +SET @@optimizer_use_condition_selectivity=4; +SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +a +34:20:30 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = '0000-00-01 10:20:30') and (length(`test`.`t1`.`a`) = 8)) +drop table t1; +SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set @@old_mode= @save_old_mode; +# # End of 10.1 tests # diff --git a/mysql-test/r/type_time_6065.result b/mysql-test/r/type_time_6065.result index a61c658d50ee5fae3323ff83969af29be1841fd1..067fe9b89fc4630bd672dc3f0668a501df5967f0 100644 --- a/mysql-test/r/type_time_6065.result +++ b/mysql-test/r/type_time_6065.result @@ -2308,3 +2308,47 @@ col_int_nokey 1 DROP TABLE t1,t2,t3; SET TIMESTAMP=0; +# +# MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)); +CREATE TABLE t2 (col_datetime_key DATETIME); +INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00'); +INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00'); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2011-12-29 22:00:00 -770:00:00 +2012-03-03 02:00:00 770:00:00 +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-29 22:00:00 -770:00:00 +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2012-03-03 02:00:00 770:00:00 +INSERT INTO t1 VALUES ('-838:59:59'),('838:59:59'); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-839:00:00' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '839:00:00' HOUR_SECOND)); +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2011-12-29 22:00:00 -770:00:00 +2012-03-03 02:00:00 770:00:00 +2011-12-27 01:00:01 -838:59:59 +2012-03-05 22:59:59 838:59:59 +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2011-12-29 22:00:00 -770:00:00 +2011-12-30 08:00:00 -760:00:00 +2012-03-02 16:00:00 760:00:00 +2012-03-03 02:00:00 770:00:00 +2011-12-27 01:00:01 -838:59:59 +2012-03-05 22:59:59 838:59:59 +DROP TABLE t1, t2; +SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index b621fc13ee4b54b6b2e6a8f22e6f4ec8f1d72e7a..df0d16237aca9bb5a4f45ba919eba6c453346412 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -568,6 +568,7 @@ set sql_safe_updates=1; set sql_select_limit=1; set sql_select_limit=default; set sql_warnings=1; +set @save_table_open_cache=@@table_open_cache; set global table_open_cache=100; set default_storage_engine=myisam; set global thread_cache_size=100; @@ -748,11 +749,11 @@ Warnings: Warning 1292 Truncated incorrect table_open_cache value: '-1' SHOW VARIABLES LIKE 'table_open_cache'; Variable_name Value -table_open_cache 1 +table_open_cache 10 SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache'; VARIABLE_NAME VARIABLE_VALUE -TABLE_OPEN_CACHE 1 -SET GLOBAL table_open_cache=DEFAULT; +TABLE_OPEN_CACHE 10 +SET GLOBAL table_open_cache=@save_table_open_cache; set character_set_results=NULL; select ifnull(@@character_set_results,"really null"); ifnull(@@character_set_results,"really null") diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 88f40b2cc9d9e6eabd902f8c6e60e57851d201bb..e8c96e4997779f61f6c20f76d312b02eb1d018ba 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5268,114 +5268,6 @@ execute stmt1; deallocate prepare stmt1; drop view v1,v2; drop table t1,t2; -# -# MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized -# with MERGE view) -# -CREATE TABLE t1 (a1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t2 (b1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t3 (c1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t4 (d1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t5 (e1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t6 (f1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE OR REPLACE view v1 AS -SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -; -SELECT 1 -FROM (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t1) -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t2) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t3) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t4) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t5) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t6) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t7) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 -FROM t1 a_alias_1 -LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 -LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 -LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 -LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 -LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t8) ON 1=1 -; -1 -SELECT 1 -FROM (v1 t1) -LEFT OUTER JOIN (v1 t2) ON 1=1 -LEFT OUTER JOIN (v1 t3) ON 1=1 -LEFT OUTER JOIN (v1 t4) ON 1=1 -LEFT OUTER JOIN (v1 t5) ON 1=1 -LEFT OUTER JOIN (v1 t6) ON 1=1 -LEFT OUTER JOIN (v1 t7) ON 1=1 -LEFT OUTER JOIN (v1 t8) ON 1=1 -; -1 -drop view v1; -drop table t1,t2,t3,t4,t5,t6; # ----------------------------------------------------------------- # -- End of 5.3 tests. # ----------------------------------------------------------------- @@ -5676,6 +5568,203 @@ View Create View character_set_client collation_connection v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select group_concat(`t1`.`str` separator '\\') AS `GROUP_CONCAT(str SEPARATOR '\\')` from `t1` latin1 latin1_swedish_ci drop view v1; drop table t1; +CREATE TABLE IF NOT EXISTS t0 (f0 INT); +CREATE TABLE IF NOT EXISTS t1 (f1 INT); +CREATE TABLE IF NOT EXISTS t2 (f2 INT); +CREATE TABLE IF NOT EXISTS t3 (f3 INT); +CREATE TABLE IF NOT EXISTS t4 (f4 INT); +CREATE TABLE IF NOT EXISTS t5 (f5 INT); +CREATE TABLE IF NOT EXISTS t6 (f6 INT); +CREATE TABLE IF NOT EXISTS t7 (f7 INT); +CREATE TABLE IF NOT EXISTS t8 (f8 INT); +CREATE TABLE IF NOT EXISTS t9 (f9 INT); +CREATE TABLE IF NOT EXISTS t10 (f10 INT); +CREATE TABLE IF NOT EXISTS t11 (f11 INT); +CREATE TABLE IF NOT EXISTS t12 (f12 INT); +CREATE TABLE IF NOT EXISTS t13 (f13 INT); +CREATE TABLE IF NOT EXISTS t14 (f14 INT); +CREATE TABLE IF NOT EXISTS t15 (f15 INT); +CREATE TABLE IF NOT EXISTS t16 (f16 INT); +CREATE TABLE IF NOT EXISTS t17 (f17 INT); +CREATE TABLE IF NOT EXISTS t18 (f18 INT); +CREATE TABLE IF NOT EXISTS t19 (f19 INT); +CREATE TABLE IF NOT EXISTS t20 (f20 INT); +CREATE TABLE IF NOT EXISTS t21 (f21 INT); +CREATE TABLE IF NOT EXISTS t22 (f22 INT); +CREATE TABLE IF NOT EXISTS t23 (f23 INT); +CREATE TABLE IF NOT EXISTS t24 (f24 INT); +CREATE TABLE IF NOT EXISTS t25 (f25 INT); +CREATE TABLE IF NOT EXISTS t26 (f26 INT); +CREATE TABLE IF NOT EXISTS t27 (f27 INT); +CREATE TABLE IF NOT EXISTS t28 (f28 INT); +CREATE TABLE IF NOT EXISTS t29 (f29 INT); +CREATE TABLE IF NOT EXISTS t30 (f30 INT); +CREATE TABLE IF NOT EXISTS t31 (f31 INT); +CREATE TABLE IF NOT EXISTS t32 (f32 INT); +CREATE TABLE IF NOT EXISTS t33 (f33 INT); +CREATE TABLE IF NOT EXISTS t34 (f34 INT); +CREATE TABLE IF NOT EXISTS t35 (f35 INT); +CREATE TABLE IF NOT EXISTS t36 (f36 INT); +CREATE TABLE IF NOT EXISTS t37 (f37 INT); +CREATE TABLE IF NOT EXISTS t38 (f38 INT); +CREATE TABLE IF NOT EXISTS t39 (f39 INT); +CREATE TABLE IF NOT EXISTS t40 (f40 INT); +CREATE TABLE IF NOT EXISTS t41 (f41 INT); +CREATE TABLE IF NOT EXISTS t42 (f42 INT); +CREATE TABLE IF NOT EXISTS t43 (f43 INT); +CREATE TABLE IF NOT EXISTS t44 (f44 INT); +CREATE TABLE IF NOT EXISTS t45 (f45 INT); +CREATE TABLE IF NOT EXISTS t46 (f46 INT); +CREATE TABLE IF NOT EXISTS t47 (f47 INT); +CREATE TABLE IF NOT EXISTS t48 (f48 INT); +CREATE TABLE IF NOT EXISTS t49 (f49 INT); +CREATE TABLE IF NOT EXISTS t50 (f50 INT); +CREATE TABLE IF NOT EXISTS t51 (f51 INT); +CREATE TABLE IF NOT EXISTS t52 (f52 INT); +CREATE TABLE IF NOT EXISTS t53 (f53 INT); +CREATE TABLE IF NOT EXISTS t54 (f54 INT); +CREATE TABLE IF NOT EXISTS t55 (f55 INT); +CREATE TABLE IF NOT EXISTS t56 (f56 INT); +CREATE TABLE IF NOT EXISTS t57 (f57 INT); +CREATE TABLE IF NOT EXISTS t58 (f58 INT); +CREATE TABLE IF NOT EXISTS t59 (f59 INT); +CREATE TABLE IF NOT EXISTS t60 (f60 INT); +CREATE OR REPLACE VIEW v60 AS SELECT * FROM t60; +EXPLAIN +SELECT t0.* +FROM t0 +JOIN t1 +ON t1.f1 = t0.f0 +LEFT JOIN t2 +ON t0.f0 = t2.f2 +LEFT JOIN t3 +ON t0.f0 = t3.f3 +LEFT JOIN t4 +ON t0.f0 = t4.f4 +LEFT JOIN t5 +ON t4.f4 = t5.f5 +LEFT JOIN t6 +ON t0.f0 = t6.f6 +LEFT JOIN t7 +ON t0.f0 = t7.f7 +LEFT JOIN t8 +ON t0.f0 = t8.f8 +LEFT JOIN t9 +ON t0.f0 = t9.f9 +LEFT JOIN t10 +ON t0.f0 = t10.f10 +LEFT JOIN t11 +ON t0.f0 = t11.f11 +LEFT JOIN t12 +ON t0.f0 = t12.f12 +LEFT JOIN t13 +ON t0.f0 = t13.f13 +LEFT JOIN t14 +ON t0.f0 = t14.f14 +LEFT JOIN t15 +ON t0.f0 = t15.f15 +LEFT JOIN t16 +ON t0.f0 = t16.f16 +LEFT JOIN t17 +ON t0.f0 = t17.f17 +LEFT JOIN t18 +ON t0.f0 = t18.f18 +LEFT JOIN t19 +ON t18.f18 = t19.f19 +LEFT JOIN t20 +ON t20.f20 = t19.f19 +LEFT JOIN t21 +ON t20.f20 = t21.f21 +LEFT JOIN t22 +ON t19.f19 = t22.f22 +LEFT JOIN t23 +ON t23.f23 = t0.f0 +LEFT JOIN t24 +ON t24.f24 = t23.f23 +LEFT JOIN t25 +ON t0.f0 = t25.f25 +LEFT JOIN t26 +ON t26.f26 = t0.f0 +LEFT JOIN t27 +ON t27.f27 = t0.f0 +LEFT JOIN t28 +ON t0.f0 = t28.f28 +LEFT JOIN t29 +ON t0.f0 = t29.f29 +LEFT JOIN t30 +ON t30.f30 = t0.f0 +LEFT JOIN t31 +ON t0.f0 = t31.f31 +LEFT JOIN t32 +ON t32.f32 = t31.f31 +LEFT JOIN t33 +ON t33.f33 = t0.f0 +LEFT JOIN t34 +ON t33.f33 = t34.f34 +LEFT JOIN t35 +ON t33.f33 = t35.f35 +LEFT JOIN t36 +ON t36.f36 = t0.f0 +LEFT JOIN t37 +ON t32.f32 = t37.f37 +LEFT JOIN t38 +ON t31.f31 = t38.f38 +LEFT JOIN t39 +ON t39.f39 = t0.f0 +LEFT JOIN t40 +ON t40.f40 = t39.f39 +LEFT JOIN t41 +ON t41.f41 = t0.f0 +LEFT JOIN t42 +ON t42.f42 = t41.f41 +LEFT JOIN t43 +ON t43.f43 = t41.f41 +LEFT JOIN t44 +ON t44.f44 = t0.f0 +LEFT JOIN t45 +ON t45.f45 = t0.f0 +LEFT JOIN t46 +ON t46.f46 = t0.f0 +LEFT JOIN t47 +ON t47.f47 = t0.f0 +LEFT JOIN t48 +ON t48.f48 = t0.f0 +LEFT JOIN t49 +ON t0.f0 = t49.f49 +LEFT JOIN t50 +ON t0.f0 = t50.f50 +LEFT JOIN t51 +ON t0.f0 = t51.f51 +LEFT JOIN t52 +ON t52.f52 = t0.f0 +LEFT JOIN t53 +ON t53.f53 = t0.f0 +LEFT JOIN t54 +ON t54.f54 = t0.f0 +LEFT JOIN t55 +ON t55.f55 = t0.f0 +LEFT JOIN t56 +ON t56.f56 = t0.f0 +LEFT JOIN t57 +ON t57.f57 = t0.f0 +LEFT JOIN t58 +ON t58.f58 = t57.f57 +LEFT JOIN t59 +ON t36.f36 = t59.f59 +LEFT JOIN v60 +ON t36.f36 = v60.f60 +; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table +drop table t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, +t10, t11, t12, t13, t14, t15, t16, t17, t18, +t19, t20, t21, t22, t23, t24, t25, t26, t27, +t28, t29, t30, t31, t32, t33, t34, t35, t36, +t37, t38, t39, t40, t41, t42, t43, t44, t45, +t46, t47, t48, t49, t50, t51, t52, t53, t54, +t55, t56, t57, t58, t59,t60; +drop view v60; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/std_data/binlog-header.log b/mysql-test/std_data/binlog-header.log deleted file mode 100644 index c415a57e61612b723f773414898f9dcf0871f98e..0000000000000000000000000000000000000000 Binary files a/mysql-test/std_data/binlog-header.log and /dev/null differ diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 4d921d1b0493b53b4a31cd2bb9ac44d6f7407284..5ac3bd3e138df5f929cdd34d0510d061adec1c6a 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -20,6 +20,9 @@ sub skip_combinations { my %skip = ( 'include/have_innodb.combinations' => [ @combinations ], 'include/have_xtradb.combinations' => [ @combinations ]); + $skip{'include/innodb_encrypt_log.combinations'} = [ 'crypt' ] + unless $ENV{DEBUG_KEY_MANAGEMENT_SO}; + # don't run tests for the wrong platform $skip{'include/platform.combinations'} = [ (IS_WINDOWS) ? 'unix' : 'win' ]; @@ -33,6 +36,9 @@ sub skip_combinations { die "unknown value max-binlog-stmt-cache-size=$longsysvar" unless $val_map{$longsysvar}; $skip{'include/word_size.combinations'} = [ $val_map{$longsysvar} ]; + $skip{'include/maybe_debug.combinations'} = + [ defined $::mysqld_variables{'debug-dbug'} ? 'release' : 'debug' ]; + # as a special case, disable certain include files as a whole $skip{'include/not_embedded.inc'} = 'Not run for embedded server' if $::opt_embedded_server; diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result index 4e4fd89d1ae519fa594966c09818eb6c04c5e553..51fc7a8cbc4a7f5f2a0b4fc6bbbcfd107f5e2707 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result @@ -1,7 +1,7 @@ -call mtr.add_suppression("InnoDB: The page .*"); -call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* "); -call mtr.add_suppression("Plugin 'file_key_management' .*"); -call mtr.add_suppression("mysqld: File .*"); +call mtr.add_suppression("Plugin 'file_key_management' init function returned error"); +call mtr.add_suppression("Plugin 'file_key_management' registration.*failed"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("mysqld: File .*keysbad3.txt' not found "); # Start server with keys2.txt SET GLOBAL innodb_file_format = `Barracuda`; @@ -28,14 +28,7 @@ foobar 2 # Restart server with keysbad3.txt SELECT * FROM t1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table test/t1 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Warning 192 Table "test"."t1" in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DROP TABLE t1; -SHOW WARNINGS; -Level Code Message # Start server with keys3.txt SET GLOBAL innodb_default_encryption_key_id=5; CREATE TABLE t2 (c VARCHAR(8), id int not null primary key, b int, key(b)) ENGINE=InnoDB ENCRYPTED=YES; @@ -44,73 +37,32 @@ INSERT INTO t2 VALUES ('foobar',1,2); # Restart server with keys2.txt SELECT * FROM t2; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table test/t2 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB SELECT * FROM t2 where id = 1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB SELECT * FROM t2 where b = 1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB INSERT INTO t2 VALUES ('tmp',3,3); ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DELETE FROM t2 where b = 3; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DELETE FROM t2 where id = 3; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB UPDATE t2 set b = b +1; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB OPTIMIZE TABLE t2; Table Op Msg_type Msg_text test.t2 optimize Warning Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. test.t2 optimize Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB test.t2 optimize error Corrupt -SHOW WARNINGS; -Level Code Message ALTER TABLE t2 ADD COLUMN d INT; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB ANALYZE TABLE t2; Table Op Msg_type Msg_text test.t2 analyze Warning Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. test.t2 analyze Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB test.t2 analyze error Corrupt -SHOW WARNINGS; -Level Code Message TRUNCATE TABLE t2; ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB -SHOW WARNINGS; -Level Code Message -Warning 192 Table "test"."t2" in file ./test/t2.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. -Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB DROP TABLE t2; # Start server with keys2.txt diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result index 94ed922a0ec48f0346d673c624c1a934bbf6af68..1ed78a9efd2aaa5742cb46b2ff9978ea4eab6e40 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result @@ -1,6 +1,5 @@ -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1new cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("Couldn't load plugins from 'file_key_management.*"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t1(new)?\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); call mtr.add_suppression("InnoDB: Table \'\"test\".\"t1\"\' tablespace is set as discarded."); SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result index 227b8cc3debc68f8d824d400bdc3a6ccd3d6b833..a491b084764f1cd3e8d26624924cc497bc4bf729 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result @@ -1,4 +1,4 @@ -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t1\\.ibd' cannot be decrypted\\."); call mtr.add_suppression("InnoDB: Cannot open table .*"); call mtr.add_suppression("InnoDB: .ibd file is missing for table test/.*"); call mtr.add_suppression("Couldn't load plugins from 'file_key_management.*"); diff --git a/mysql-test/suite/encryption/r/innodb-compressed-blob.result b/mysql-test/suite/encryption/r/innodb-compressed-blob.result index 15c2a4109488f950fb638aa47068f712fd88dbc7..ce73b80820fbd2f092025260ef5e2045568738f2 100644 --- a/mysql-test/suite/encryption/r/innodb-compressed-blob.result +++ b/mysql-test/suite/encryption/r/innodb-compressed-blob.result @@ -1,5 +1,4 @@ -call mtr.add_suppression("InnoDB: However key management plugin or used key_version .*"); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-3] cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '..test.t[1-3]\\.ibd' cannot be decrypted\\."); call mtr.add_suppression("Unable to decompress space ..test.t[1-3].ibd \\[[1-9][0-9]*:[0-9]+\\]"); # Restart mysqld --file-key-management-filename=keys2.txt SET GLOBAL innodb_file_format = `Barracuda`; diff --git a/mysql-test/suite/encryption/r/innodb-discard-import.result b/mysql-test/suite/encryption/r/innodb-discard-import.result index 06f4abab9f40b411f07d6465980e44ff8a4febe2..406460d0a2390bb4c22e22d64fb5f465d250653f 100644 --- a/mysql-test/suite/encryption/r/innodb-discard-import.result +++ b/mysql-test/suite/encryption/r/innodb-discard-import.result @@ -1,5 +1,8 @@ call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .* for how to resolve the issue."); +SET @innodb_file_format_orig = @@GLOBAL.innodb_file_format; +SET @innodb_file_per_table_orig = @@GLOBAL.innodb_file_per_table; +SET @innodb_compression_algo = @@GLOBAL.innodb_compression_algorithm; SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_compression_algorithm = 1; @@ -134,3 +137,6 @@ NOT FOUND /tmpres/ in t3.ibd NOT FOUND /mysql/ in t4.ibd DROP PROCEDURE innodb_insert_proc; DROP TABLE t1,t2,t3,t4; +SET GLOBAL innodb_file_format = @innodb_file_format_orig; +SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; +SET GLOBAL innodb_compression_algorithm = @innodb_compression_algo; diff --git a/mysql-test/suite/encryption/r/innodb-encryption-disable.result b/mysql-test/suite/encryption/r/innodb-encryption-disable.result index dd2b025553e680d641d34d7c98cf7c04b059f103..4d15098d936329172e370cf1e1d1aad72f384b96 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-disable.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-disable.result @@ -1,5 +1,4 @@ -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t5 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\."); call mtr.add_suppression("Couldn't load plugins from 'file_key_management*"); create table t5 ( `intcol1` int(32) DEFAULT NULL, diff --git a/mysql-test/suite/encryption/r/innodb-force-corrupt.result b/mysql-test/suite/encryption/r/innodb-force-corrupt.result index 3f3a2afb02d99aa2b3f6109077be5b38fe4d9cd8..7d63f47d17ee6ddaba24494c141222dcd7ce8640 100644 --- a/mysql-test/suite/encryption/r/innodb-force-corrupt.result +++ b/mysql-test/suite/encryption/r/innodb-force-corrupt.result @@ -1,9 +1,5 @@ -CALL mtr.add_suppression("InnoDB: Database page corruption on disk or a failed .*"); -CALL mtr.add_suppression("InnoDB: Corruption: Block in space_id .*"); -CALL mtr.add_suppression("InnoDB: However key management plugin or used key_version .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t[0-9]+ page \[page id: space=[0-9]+, page number=[0-9]+\]. You may have to recover from a backup."); SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; set global innodb_compression_algorithm = 1; diff --git a/mysql-test/suite/encryption/r/innodb-missing-key.result b/mysql-test/suite/encryption/r/innodb-missing-key.result index 2f2cc0259733871bc9114335c735971926c85bbd..53ca0845c254ab4c71e78d542fa04c5c0196542f 100644 --- a/mysql-test/suite/encryption/r/innodb-missing-key.result +++ b/mysql-test/suite/encryption/r/innodb-missing-key.result @@ -1,6 +1,4 @@ -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); # Start server with keys2.txt CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19; diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index e12dad6d0d732d71e3c854e108e0dd7eacd4ad45..ed578d80b3a782e35f78e4dbb95d6ab2b6fff3f2 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -1,16 +1,13 @@ call mtr.add_suppression("InnoDB: Block in space_id .* in file .* encrypted."); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("Plugin 'file_key_management' "); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: Read operation failed for tablespace .*"); -call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed.*"); -call mtr.add_suppression("InnoDB: Recovery read page .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE .*"); -call mtr.add_suppression("InnoDB: Plugin initialization aborted .*"); +call mtr.add_suppression("InnoDB: Read operation failed for tablespace "); +call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed"); +call mtr.add_suppression("InnoDB: Recovery read page "); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[1234]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE "); +call mtr.add_suppression("InnoDB: Plugin initialization aborted "); call mtr.add_suppression("InnoDB: ############### CORRUPT LOG RECORD FOUND ##################"); # Restart mysqld --file-key-management-filename=keys2.txt # Wait max 10 min for key encryption threads to encrypt all spaces diff --git a/mysql-test/suite/encryption/r/innodb-redo-nokeys.result b/mysql-test/suite/encryption/r/innodb-redo-nokeys.result index dcbe1f5a395a8030a667ba46b3acfe30a010424f..1ea706dbde450a297ef18cab8905cd4f41d6e748 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-nokeys.result +++ b/mysql-test/suite/encryption/r/innodb-redo-nokeys.result @@ -1,13 +1,10 @@ -call mtr.add_suppression("InnoDB: Block in space_id .*"); -call mtr.add_suppression("mysqld: File .*"); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("InnoDB: Block in space_id "); +call mtr.add_suppression("mysqld: File "); +call mtr.add_suppression("Plugin 'file_key_management' "); call mtr.add_suppression("InnoDB: cannot enable encryption, encryption plugin is not available"); -call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error\\."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[1234]\\.ibd' cannot be decrypted\\."); # Restart mysqld --file-key-management-filename=keys2.txt SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; diff --git a/mysql-test/suite/encryption/r/innodb-remove-encryption.result b/mysql-test/suite/encryption/r/innodb-remove-encryption.result new file mode 100644 index 0000000000000000000000000000000000000000..06f1c986a25f642ec2d6f27f28eaeccc18e4ee5e --- /dev/null +++ b/mysql-test/suite/encryption/r/innodb-remove-encryption.result @@ -0,0 +1,41 @@ +set global innodb_file_per_table=OFF; +call mtr.add_suppression("mysqld: file-key-management-filename is not set"); +call mtr.add_suppression("Plugin 'file_key_management' init function returned error."); +call mtr.add_suppression("Plugin 'file_key_management' registration as a ENCRYPTION failed."); +flush tables; +create table t1(a int not null primary key, b char(200)) engine=innodb; + +# Restart server with encryption +# Wait until encryption threads have encrypted all tablespaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +./ibdata1 +# Success! +SELECT * from t1; +a b +# Now turn off encryption and wait for threads to decrypt all tablespaces +SET GLOBAL innodb_encrypt_tables = off; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +./ibdata1 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +# Success! + +# Restart server with no encryption setup, there should be no crashes +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +./ibdata1 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +SELECT * from t1; +a b +DROP TABLE t1; diff --git a/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result b/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result index ec92825ac8e7547944486664b09b18c40055fc0f..14933e526c4514895bf9ee81c48b524d1cb92b4f 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result +++ b/mysql-test/suite/encryption/r/innodb_encryption-page-compression.result @@ -1,5 +1,4 @@ SET GLOBAL innodb_file_format = `Barracuda`; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_encrypt_tables = on; set global innodb_compression_algorithm = 1; @@ -136,18 +135,19 @@ count(*) select count(*) from innodb_page_compressed9 where c1 < 500000; count(*) 2000 +flush tables innodb_page_compressed1, innodb_page_compressed2, +innodb_page_compressed3, innodb_page_compressed4, +innodb_page_compressed5, innodb_page_compressed6, +innodb_page_compressed7, innodb_page_compressed8, +innodb_page_compressed9 for export; +unlock tables; +# Wait until dirty pages are compressed and encrypted SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_encrypted'; variable_value > 0 1 -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_decrypted'; -variable_value >= 0 -1 SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_compressed'; variable_value > 0 1 -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; -variable_value >= 0 -1 SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_encrypt_tables = off; update innodb_page_compressed1 set c1 = c1 + 1; @@ -159,17 +159,22 @@ update innodb_page_compressed6 set c1 = c1 + 1; update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1; -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_encrypted'; -variable_value >= 0 -1 +flush tables innodb_page_compressed1, innodb_page_compressed2, +innodb_page_compressed3, innodb_page_compressed4, +innodb_page_compressed5, innodb_page_compressed6, +innodb_page_compressed7, innodb_page_compressed8, +innodb_page_compressed9 for export; +unlock tables; +# Wait until dirty pages are compressed and encrypted 2 +unlock tables; SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_decrypted'; variable_value > 0 1 SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_compressed'; variable_value > 0 1 -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; -variable_value >= 0 +SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; +variable_value > 0 1 drop procedure innodb_insert_proc; drop table innodb_normal; diff --git a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result index d08a6e943f4c62470a11ea66914e8a829126b1b6..a2a4f25b026ef8fb1b2b6d74eb4496110198deb0 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result +++ b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result @@ -73,6 +73,8 @@ NOT FOUND /foobar/ in t1.ibd NOT FOUND /temp/ in t2.ibd # t3 ... on expecting NOT FOUND NOT FOUND /barfoo/ in t3.ibd +SET GLOBAL innodb_file_format = `Barracuda`; +SET GLOBAL innodb_file_per_table = ON; ALTER TABLE t1 ENGINE InnoDB; SHOW CREATE TABLE t1; Table Create Table diff --git a/mysql-test/suite/encryption/r/innodb_encryption_filekeys.result b/mysql-test/suite/encryption/r/innodb_encryption_filekeys.result index ab958004eaba4c74b3fb43070106ce1b6c101d9b..1c8341137b4d73ab52a7e61f8b48aeed70882e59 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption_filekeys.result +++ b/mysql-test/suite/encryption/r/innodb_encryption_filekeys.result @@ -1,6 +1,4 @@ -call mtr.add_suppression("trying to do an operation on a dropped tablespace .*"); SET GLOBAL innodb_file_format = `Barracuda`; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = OFF; SET GLOBAL innodb_encryption_threads = 4; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; @@ -14,24 +12,21 @@ t1 CREATE TABLE `t1` ( CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=YES; CREATE TABLE t3 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO; CREATE TABLE t4 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; -INSERT INTO t2 select * from t1; -INSERT INTO t3 select * from t1; -INSERT INTO t4 select * from t1; SET GLOBAL innodb_encrypt_tables = on; # Wait max 10 min for key encryption threads to encrypt required all spaces # Success! SELECT COUNT(1) FROM t1; COUNT(1) -400 +10 SELECT COUNT(1) FROM t2; COUNT(1) -400 +10 SELECT COUNT(1) FROM t3; COUNT(1) -400 +10 SELECT COUNT(1) FROM t4; COUNT(1) -400 +10 SET GLOBAL innodb_encrypt_tables = off; # Wait max 10 min for key encryption threads to decrypt all required spaces # Success! @@ -50,18 +45,17 @@ INSERT INTO t5 select * from t1; # Success! SELECT COUNT(1) FROM t1; COUNT(1) -400 +10 SELECT COUNT(1) FROM t2; COUNT(1) -400 +10 SELECT COUNT(1) FROM t3; COUNT(1) -400 +10 SELECT COUNT(1) FROM t4; COUNT(1) -400 +10 SELECT COUNT(1) FROM t5; COUNT(1) -400 +10 drop table t1,t2,t3,t4, t5; -set GLOBAL innodb_default_encryption_key_id=1; diff --git a/mysql-test/suite/encryption/r/tempfiles.result b/mysql-test/suite/encryption/r/tempfiles.result index a0b7596dd5a976c4fcdd4810563a257af1099357..658b7dc291bc84f725f7c03e95794aed497c1f1a 100644 --- a/mysql-test/suite/encryption/r/tempfiles.result +++ b/mysql-test/suite/encryption/r/tempfiles.result @@ -1,3 +1,6 @@ +select @@encrypt_tmp_files; +@@encrypt_tmp_files +1 CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(1),(2); DELETE FROM t1 WHERE a=1; @@ -25,6 +28,7 @@ h 10 i 10 j 10 drop table t1; +reset master; set global binlog_cache_size=8192; create table t1 (a text) engine=innodb; start transaction; @@ -33,14 +37,67 @@ commit; start transaction; insert t1 select repeat(seq, 1000) from seq_1_to_8; commit; -drop table t1; -create table t1 (a text) engine=innodb; +create table t2 (a text) engine=innodb; start transaction; -insert t1 select repeat(seq, 1000) from seq_1_to_15; +insert t2 select repeat(seq, 1000) from seq_1_to_15; savepoint foo; -insert t1 select repeat(seq, 1000) from seq_16_to_30; +insert t2 select repeat(seq, 1000) from seq_16_to_30; rollback to savepoint foo; -insert t1 select repeat(seq, 1000) from seq_31_to_40; +insert t2 select repeat(seq, 1000) from seq_31_to_40; commit; -drop table t1; +flush binary logs; +drop table t1, t2; set global binlog_cache_size=default; +select left(a, 10) from t1; +left(a, 10) +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +9999999999 +1010101010 +1111111111 +1212121212 +1313131313 +1414141414 +1515151515 +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +select left(a, 10) from t2; +left(a, 10) +1111111111 +2222222222 +3333333333 +4444444444 +5555555555 +6666666666 +7777777777 +8888888888 +9999999999 +1010101010 +1111111111 +1212121212 +1313131313 +1414141414 +1515151515 +3131313131 +3232323232 +3333333333 +3434343434 +3535353535 +3636363636 +3737373737 +3838383838 +3939393939 +4040404040 +drop table t1, t2; diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test index 66546872c25a5c795f9348c74b5838517c106093..9d61770f543e35aa9f2e349d22f90523a172b6e1 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test @@ -8,10 +8,11 @@ # table exists and encryption service is not available. # -call mtr.add_suppression("InnoDB: The page .*"); -call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* "); -call mtr.add_suppression("Plugin 'file_key_management' .*"); -call mtr.add_suppression("mysqld: File .*"); +call mtr.add_suppression("Plugin 'file_key_management' init function returned error"); +call mtr.add_suppression("Plugin 'file_key_management' registration.*failed"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("mysqld: File .*keysbad3.txt' not found "); + --echo --echo # Start server with keys2.txt @@ -40,18 +41,18 @@ SELECT * FROM t1; -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt -- source include/restart_mysqld.inc +--disable_warnings --error ER_GET_ERRMSG SELECT * FROM t1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; +--enable_warnings -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt -- source include/restart_mysqld.inc +--disable_warnings --replace_regex /tablespace [0-9]*/tablespace / DROP TABLE t1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; +--enable_warnings # # MDEV-8591: Database page corruption on disk or a failed space, Assertion failure in file buf0buf.cc @@ -71,51 +72,41 @@ INSERT INTO t2 VALUES ('foobar',1,2); -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc +--disable_warnings --error ER_GET_ERRMSG SELECT * FROM t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG SELECT * FROM t2 where id = 1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG SELECT * FROM t2 where b = 1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --replace_regex /tablespace [0-9]*/tablespace / --error ER_GET_ERRMSG INSERT INTO t2 VALUES ('tmp',3,3); ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG DELETE FROM t2 where b = 3; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG DELETE FROM t2 where id = 3; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG UPDATE t2 set b = b +1; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + OPTIMIZE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG ALTER TABLE t2 ADD COLUMN d INT; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + ANALYZE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; + --error ER_GET_ERRMSG TRUNCATE TABLE t2; ---replace_regex /tablespace [0-9]*/tablespace / /key_id [0-9]*/key_id / -SHOW WARNINGS; DROP TABLE t2; +--enable_warnings --echo --echo # Start server with keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test index 52ee442c725cc6d2d629218847d39c52d69dd15d..0c312f1f449be2af355d1224b7a66c53c33a7e23 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test @@ -8,10 +8,9 @@ # MDEV-8768: Server crash at file btr0btr.ic line 122 when checking encrypted table using incorrect keys # MDEV-8727: Server/InnoDB hangs on shutdown after trying to read an encrypted table with a wrong key # -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1new cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t1(new)?\\.ibd' cannot be decrypted\\."); # Suppression for builds where file_key_management plugin is linked statically -call mtr.add_suppression("Couldn't load plugins from 'file_key_management.*"); +call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); call mtr.add_suppression("InnoDB: Table \'\"test\".\"t1\"\' tablespace is set as discarded."); --let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test index 14d88614f55d722494c433c9af7f639679056a27..0c52bfe3fe6444df9305609e8cc1cd104c20a7e8 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test @@ -7,7 +7,7 @@ # MDEV-8768: Server crash at file btr0btr.ic line 122 when checking encrypted table using incorrect keys # -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t1\\.ibd' cannot be decrypted\\."); call mtr.add_suppression("InnoDB: Cannot open table .*"); call mtr.add_suppression("InnoDB: .ibd file is missing for table test/.*"); # Suppression for builds where file_key_management plugin is linked statically diff --git a/mysql-test/suite/encryption/t/innodb-compressed-blob.test b/mysql-test/suite/encryption/t/innodb-compressed-blob.test index cb69f22f7450bed83f68c14d1b6cc880354240a2..4a81dae5a0f323fd2e32be73188e26a963618c1b 100644 --- a/mysql-test/suite/encryption/t/innodb-compressed-blob.test +++ b/mysql-test/suite/encryption/t/innodb-compressed-blob.test @@ -4,8 +4,7 @@ # embedded does not support restart -- source include/not_embedded.inc -call mtr.add_suppression("InnoDB: However key management plugin or used key_version .*"); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-3] cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '..test.t[1-3]\\.ibd' cannot be decrypted\\."); call mtr.add_suppression("Unable to decompress space ..test.t[1-3].ibd \\[[1-9][0-9]*:[0-9]+\\]"); --echo # Restart mysqld --file-key-management-filename=keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-discard-import.test b/mysql-test/suite/encryption/t/innodb-discard-import.test index 9feaacc41e51bb1fbc80900276b14f21c25bb334..54471ae3baed64a8b6fbf79cdc716481651a4493 100644 --- a/mysql-test/suite/encryption/t/innodb-discard-import.test +++ b/mysql-test/suite/encryption/t/innodb-discard-import.test @@ -1,10 +1,6 @@ -- source include/have_innodb.inc +-- source include/innodb_page_size_small.inc -- source include/have_file_key_management_plugin.inc -# embedded does not support restart --- source include/not_embedded.inc --- source include/not_valgrind.inc -# Avoid CrashReporter popup on Mac --- source include/not_crashrep.inc # # MDEV-8770: Incorrect error message when importing page compressed tablespace @@ -13,17 +9,13 @@ call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .* for how to resolve the issue."); ---disable_query_log -let $innodb_file_format_orig = `SELECT @@innodb_file_format`; -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; -let $innodb_compression_algo = `SELECT @@innodb_compression_algorithm`; ---enable_query_log +SET @innodb_file_format_orig = @@GLOBAL.innodb_file_format; +SET @innodb_file_per_table_orig = @@GLOBAL.innodb_file_per_table; +SET @innodb_compression_algo = @@GLOBAL.innodb_compression_algorithm; ---disable_warnings SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_compression_algorithm = 1; ---enable_warnings --let $MYSQLD_TMPDIR = `SELECT @@tmpdir` --let $MYSQLD_DATADIR = `SELECT @@datadir` @@ -37,7 +29,9 @@ create table t1(c1 bigint not null, b char(200)) engine=innodb encrypted=yes en show warnings; create table t2(c1 bigint not null, b char(200)) engine=innodb page_compressed=1 encrypted=yes encryption_key_id=4; show warnings; -create table t3(c1 bigint not null, b char(200)) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4; +let $kbs= `select floor(@@global.innodb_page_size/1024)`; +--replace_regex / key_block_size=\d+//i +eval create table t3(c1 bigint not null, b char(200)) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4 key_block_size=$kbs; show warnings; create table t4(c1 bigint not null, b char(200)) engine=innodb page_compressed=1; show warnings; @@ -98,6 +92,7 @@ ALTER TABLE t2 IMPORT TABLESPACE; SHOW CREATE TABLE t2; SELECT COUNT(*) FROM t2; ALTER TABLE t3 IMPORT TABLESPACE; +--replace_regex / key_block_size=\d+//i SHOW CREATE TABLE t3; SELECT COUNT(*) FROM t3; ALTER TABLE t4 IMPORT TABLESPACE; @@ -125,11 +120,6 @@ SELECT COUNT(*) FROM t4; DROP PROCEDURE innodb_insert_proc; DROP TABLE t1,t2,t3,t4; -# reset system ---disable_warnings ---disable_query_log -EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; -EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig; -EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algo; ---enable_query_log ---enable_warnings +SET GLOBAL innodb_file_format = @innodb_file_format_orig; +SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; +SET GLOBAL innodb_compression_algorithm = @innodb_compression_algo; diff --git a/mysql-test/suite/encryption/t/innodb-encryption-disable.test b/mysql-test/suite/encryption/t/innodb-encryption-disable.test index 38f36076c7329d19dd40153068b6b1465da31617..6ade8d6e3b28c9afee15f2af17e3fbcc285df72a 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-disable.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-disable.test @@ -7,8 +7,7 @@ # MDEV-9559: Server without encryption configs crashes if selecting from an implicitly encrypted table # -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t5 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\."); # Suppression for builds where file_key_management plugin is linked statically call mtr.add_suppression("Couldn't load plugins from 'file_key_management*"); diff --git a/mysql-test/suite/encryption/t/innodb-force-corrupt.test b/mysql-test/suite/encryption/t/innodb-force-corrupt.test index dd4ee51b1eb5c1dd3e0be43a8a877c028488edc8..cb6440127ccb5c69aff2000b6804c5aa6552117b 100644 --- a/mysql-test/suite/encryption/t/innodb-force-corrupt.test +++ b/mysql-test/suite/encryption/t/innodb-force-corrupt.test @@ -7,12 +7,8 @@ # Don't test under embedded -- source include/not_embedded.inc -CALL mtr.add_suppression("InnoDB: Database page corruption on disk or a failed .*"); -CALL mtr.add_suppression("InnoDB: Corruption: Block in space_id .*"); -CALL mtr.add_suppression("InnoDB: However key management plugin or used key_version .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t[0-9]+ page \[page id: space=[0-9]+, page number=[0-9]+\]. You may have to recover from a backup."); --disable_warnings SET GLOBAL innodb_file_format = `Barracuda`; diff --git a/mysql-test/suite/encryption/t/innodb-missing-key.test b/mysql-test/suite/encryption/t/innodb-missing-key.test index 07a2b16211c7081a9d7ee4d01c978db046602d0f..6ea0528825b89e0ddab40b81b14185c03c391c01 100644 --- a/mysql-test/suite/encryption/t/innodb-missing-key.test +++ b/mysql-test/suite/encryption/t/innodb-missing-key.test @@ -7,9 +7,7 @@ # MDEV-11004: Unable to start (Segfault or os error 2) when encryption key missing # -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); --echo --echo # Start server with keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 159646541c7ea71be9bb95b5deeab7cd03495d4a..69de4f0f9213f4ccf5b0ca5139efa6351f71ab0b 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -4,18 +4,15 @@ -- source include/not_embedded.inc call mtr.add_suppression("InnoDB: Block in space_id .* in file .* encrypted."); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("Plugin 'file_key_management' "); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: Read operation failed for tablespace .*"); -call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed.*"); -call mtr.add_suppression("InnoDB: Recovery read page .*"); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); -call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE .*"); -call mtr.add_suppression("InnoDB: Plugin initialization aborted .*"); +call mtr.add_suppression("InnoDB: Read operation failed for tablespace "); +call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed"); +call mtr.add_suppression("InnoDB: Recovery read page "); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[1234]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE "); +call mtr.add_suppression("InnoDB: Plugin initialization aborted "); call mtr.add_suppression("InnoDB: ############### CORRUPT LOG RECORD FOUND ##################"); --echo # Restart mysqld --file-key-management-filename=keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-redo-nokeys.test b/mysql-test/suite/encryption/t/innodb-redo-nokeys.test index e55e2ade15398d70e75ea00395c5b2a09e7b5a0a..68d831fcd175730315fc752e172a24fabf4c353f 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-nokeys.test +++ b/mysql-test/suite/encryption/t/innodb-redo-nokeys.test @@ -3,16 +3,13 @@ # embedded does not support restart -- source include/not_embedded.inc -call mtr.add_suppression("InnoDB: Block in space_id .*"); -call mtr.add_suppression("mysqld: File .*"); -call mtr.add_suppression("Plugin 'file_key_management' .*"); +call mtr.add_suppression("InnoDB: Block in space_id "); +call mtr.add_suppression("mysqld: File "); +call mtr.add_suppression("Plugin 'file_key_management' "); call mtr.add_suppression("InnoDB: cannot enable encryption, encryption plugin is not available"); -call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error\\."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t2 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t3 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t4 cannot be decrypted."); -call mtr.add_suppression("InnoDB: The page \[page id: space=[0-9]+, page number=[0-9]+\] in file test/t1 cannot be decrypted."); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[1234]\\.ibd' cannot be decrypted\\."); --echo # Restart mysqld --file-key-management-filename=keys2.txt -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt diff --git a/mysql-test/suite/encryption/t/innodb-remove-encryption.test b/mysql-test/suite/encryption/t/innodb-remove-encryption.test new file mode 100644 index 0000000000000000000000000000000000000000..24e00a00a02213aeb743bda28cd787666e29cf0d --- /dev/null +++ b/mysql-test/suite/encryption/t/innodb-remove-encryption.test @@ -0,0 +1,59 @@ +--source include/have_innodb.inc +# Test uses restart +--source include/not_embedded.inc +--source filekeys_plugin.inc + +# +# MDEV-15566: System tablespace does not easily key rotate to unencrypted +# + +set global innodb_file_per_table=OFF; + +call mtr.add_suppression("mysqld: file-key-management-filename is not set"); +call mtr.add_suppression("Plugin 'file_key_management' init function returned error."); +call mtr.add_suppression("Plugin 'file_key_management' registration as a ENCRYPTION failed."); +flush tables; + +create table t1(a int not null primary key, b char(200)) engine=innodb; + +--echo +--echo # Restart server with encryption +-- let $restart_parameters=--plugin-load-add=$FILE_KEY_MANAGEMENT_SO --loose-file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 +-- source include/restart_mysqld.inc + +--echo # Wait until encryption threads have encrypted all tablespaces + +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND ROTATING_OR_FLUSHING = 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + +--echo # Success! + +SELECT * from t1; + +--echo # Now turn off encryption and wait for threads to decrypt all tablespaces +SET GLOBAL innodb_encrypt_tables = off; + +--let $wait_condition=SELECT COUNT(*) = $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + +--echo # Success! + +--echo +--echo # Restart server with no encryption setup, there should be no crashes +--let $restart_parameters=--skip-file-key-management --innodb-encrypt-tables=OFF --innodb-encryption-threads=0 --innodb-tablespaces-encryption +-- source include/restart_mysqld.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + +SELECT * from t1; +DROP TABLE t1; + diff --git a/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test b/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test index ea6bd65d6050e6f169ea59940da38c7743046272..fe132c0c59b487ac20f958a46069a4279c2d2c19 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test +++ b/mysql-test/suite/encryption/t/innodb_encryption-page-compression.test @@ -1,17 +1,14 @@ -- source include/have_innodb.inc -- source include/have_example_key_management_plugin.inc +-- source include/not_embedded.inc --disable_query_log -let $innodb_compression_algorithm_orig=`SELECT @@innodb_compression_algorithm`; -let $innodb_file_format_orig = `SELECT @@innodb_file_format`; -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; let $innodb_encrypt_tables_orig = `SELECT @@innodb_encrypt_tables`; let $innodb_encryption_threads_orig = `SELECT @@innodb_encryption_threads`; --enable_query_log --disable_warnings SET GLOBAL innodb_file_format = `Barracuda`; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_encrypt_tables = on; --enable_warnings @@ -84,13 +81,24 @@ select count(*) from innodb_page_compressed7 where c1 < 500000; select count(*) from innodb_page_compressed8 where c1 < 500000; select count(*) from innodb_page_compressed9 where c1 < 500000; +flush tables innodb_page_compressed1, innodb_page_compressed2, +innodb_page_compressed3, innodb_page_compressed4, +innodb_page_compressed5, innodb_page_compressed6, +innodb_page_compressed7, innodb_page_compressed8, +innodb_page_compressed9 for export; + +unlock tables; + +--echo # Wait until dirty pages are compressed and encrypted let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_PAGE_COMPRESSED'; --source include/wait_condition.inc +let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_ENCRYPTED'; +--source include/wait_condition.inc SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_encrypted'; -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_decrypted'; SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_compressed'; -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; + +--source include/restart_mysqld.inc SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_encrypt_tables = off; @@ -105,13 +113,23 @@ update innodb_page_compressed7 set c1 = c1 + 1; update innodb_page_compressed8 set c1 = c1 + 1; update innodb_page_compressed9 set c1 = c1 + 1; +flush tables innodb_page_compressed1, innodb_page_compressed2, +innodb_page_compressed3, innodb_page_compressed4, +innodb_page_compressed5, innodb_page_compressed6, +innodb_page_compressed7, innodb_page_compressed8, +innodb_page_compressed9 for export; +unlock tables; + +--echo # Wait until dirty pages are compressed and encrypted 2 +let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_PAGE_COMPRESSED'; +--source include/wait_condition.inc +unlock tables; let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_DECRYPTED'; --source include/wait_condition.inc -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_encrypted'; SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_decrypted'; SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_compressed'; -SELECT variable_value >= 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; +SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_page_decompressed'; drop procedure innodb_insert_proc; drop table innodb_normal; @@ -127,9 +145,6 @@ drop table innodb_page_compressed9; # reset system --disable_query_log -EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig; -EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; -EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig; EVAL SET GLOBAL innodb_encrypt_tables = $innodb_encrypt_tables_orig; EVAL SET GLOBAL innodb_encryption_threads = $innodb_encryption_threads_orig; --enable_query_log diff --git a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test index 192233a535fdbcb82238ef846763ef2bedccaf61..29c762a5d0fd614eba7f32f76cf025fb605a7121 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test +++ b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test @@ -50,10 +50,12 @@ set autocommit=1; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0 --source include/wait_condition.inc ---sleep 5 +# shutdown so that grep is safe +--source include/shutdown_mysqld.inc + --echo # tablespaces should be now encrypted --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND @@ -68,7 +70,9 @@ set autocommit=1; -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc +--source include/start_mysqld.inc let MYSQLD_DATADIR =`SELECT @@datadir`; + --list_files $MYSQLD_DATADIR/test FLUSH TABLES t1, t2, t3 FOR EXPORT; perl; @@ -95,7 +99,9 @@ SELECT COUNT(1) FROM t2; ALTER TABLE t3 IMPORT TABLESPACE; SELECT COUNT(1) FROM t3; ---sleep 5 +# shutdown so that grep is safe +--source include/shutdown_mysqld.inc + --echo # tablespaces should remain encrypted after import --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND @@ -110,6 +116,13 @@ SELECT COUNT(1) FROM t3; -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc +--source include/start_mysqld.inc + +--disable_warnings +SET GLOBAL innodb_file_format = `Barracuda`; +SET GLOBAL innodb_file_per_table = ON; +--enable_warnings + ALTER TABLE t1 ENGINE InnoDB; SHOW CREATE TABLE t1; ALTER TABLE t2 ENGINE InnoDB; @@ -126,7 +139,9 @@ SELECT COUNT(1) FROM t1; SELECT COUNT(1) FROM t2; SELECT COUNT(1) FROM t3; ---sleep 5 +# shutdown so that grep is safe +--source include/shutdown_mysqld.inc + --echo # Tablespaces should be encrypted after restart --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND @@ -141,9 +156,11 @@ SELECT COUNT(1) FROM t3; -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc +--source include/start_mysqld.inc + --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 ---let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0 --source include/wait_condition.inc --echo # Success! diff --git a/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test b/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test index 8f0986071f123cfba7ad69cb567bb48221208377..60afb6033ace9d70f816412ae4ad695f6182968f 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test +++ b/mysql-test/suite/encryption/t/innodb_encryption_filekeys.test @@ -1,21 +1,18 @@ -- source include/have_innodb.inc -- source include/have_file_key_management_plugin.inc -# embedded does not support restart --- source include/not_embedded.inc - -call mtr.add_suppression("trying to do an operation on a dropped tablespace .*"); --disable_query_log let $innodb_file_format_orig = `SELECT @@innodb_file_format`; -let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; let $encrypt_tables = `SELECT @@innodb_encrypt_tables`; let $threads = `SELECT @@innodb_encryption_threads`; +let $key_id = `SELECT @@innodb_default_encryption_key_id`; --enable_query_log +--disable_warnings SET GLOBAL innodb_file_format = `Barracuda`; -SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_encrypt_tables = OFF; SET GLOBAL innodb_encryption_threads = 4; +--enable_warnings CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; SHOW CREATE TABLE t1; @@ -25,21 +22,20 @@ CREATE TABLE t4 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNOD --disable_warnings --disable_query_log -set autocommit=0; -let $i = 400; +begin; +let $i = 10; while ($i) { INSERT INTO t1 values(NULL, substring(MD5(RAND()), -128)); dec $i; } -commit; -set autocommit=1; ---enable_warnings ---enable_query_log INSERT INTO t2 select * from t1; INSERT INTO t3 select * from t1; INSERT INTO t4 select * from t1; +commit; +--enable_warnings +--enable_query_log SET GLOBAL innodb_encrypt_tables = on; @@ -60,7 +56,7 @@ while ($cnt) } if (!$success) { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; + SELECT NAME,ENCRYPTION_SCHEME,MIN_KEY_VERSION, ROTATING_OR_FLUSHING FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; SHOW STATUS LIKE 'innodb_encryption%'; -- die Timeout waiting for encryption threads } @@ -90,7 +86,7 @@ while ($cnt) } if (!$success) { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; + SELECT NAME,ENCRYPTION_SCHEME,MIN_KEY_VERSION, ROTATING_OR_FLUSHING FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; SHOW STATUS LIKE 'innodb_encryption%'; -- die Timeout waiting for encryption threads } @@ -119,7 +115,7 @@ while ($cnt) } if (!$success) { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; + SELECT NAME,ENCRYPTION_SCHEME,MIN_KEY_VERSION, ROTATING_OR_FLUSHING FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; SHOW STATUS LIKE 'innodb_encryption%'; -- die Timeout waiting for encryption threads } @@ -131,15 +127,16 @@ SELECT COUNT(1) FROM t3; SELECT COUNT(1) FROM t4; SELECT COUNT(1) FROM t5; +drop table t1,t2,t3,t4, t5; + # reset system --disable_query_log -EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; +--disable_warnings EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig; EVAL SET GLOBAL innodb_encrypt_tables = $encrypt_tables; EVAL SET GLOBAL innodb_encryption_threads = $threads; +EVAL set GLOBAL innodb_default_encryption_key_id = $key_id; +--enable_warnings --enable_query_log -drop table t1,t2,t3,t4, t5; - -set GLOBAL innodb_default_encryption_key_id=1; diff --git a/mysql-test/suite/encryption/t/tempfiles.combinations b/mysql-test/suite/encryption/t/tempfiles.combinations new file mode 100644 index 0000000000000000000000000000000000000000..7010d2c100db9930c45f854292761b2f47f32257 --- /dev/null +++ b/mysql-test/suite/encryption/t/tempfiles.combinations @@ -0,0 +1,5 @@ +[none] +binlog-checksum=NONE + +[crc32] +binlog-checksum=CRC32 diff --git a/mysql-test/suite/encryption/t/tempfiles.opt b/mysql-test/suite/encryption/t/tempfiles.opt new file mode 100644 index 0000000000000000000000000000000000000000..2b90f474428371ec75f5dc7fdbe32a89373cfda9 --- /dev/null +++ b/mysql-test/suite/encryption/t/tempfiles.opt @@ -0,0 +1 @@ +--encrypt-tmp-files diff --git a/mysql-test/suite/encryption/t/tempfiles.test b/mysql-test/suite/encryption/t/tempfiles.test index 34dcbdf5963cde049b6a9186871a15ce675a33ba..5232bcb5d12772538af246826dd5a08775c668ee 100644 --- a/mysql-test/suite/encryption/t/tempfiles.test +++ b/mysql-test/suite/encryption/t/tempfiles.test @@ -11,6 +11,8 @@ source include/have_binlog_format_row.inc; # engine. But there's no need to run it twice for InnoDB and XtraDB. source include/have_xtradb.inc; +select @@encrypt_tmp_files; + # # MyISAM messing around with IO_CACHE::file # @@ -31,6 +33,7 @@ update t1 set c=v, t=v; select sql_big_result t,count(t) from t1 group by t limit 10; drop table t1; +reset master; set global binlog_cache_size=8192; connect con1, localhost, root; @@ -48,7 +51,6 @@ commit; start transaction; insert t1 select repeat(seq, 1000) from seq_1_to_8; commit; -drop table t1; disconnect con1; connect con2, localhost, root; @@ -58,17 +60,27 @@ connect con2, localhost, root; # Start a transaction, write until the cache goes to disk, # create a savepoint, write more blocks to disk, rollback to savepoint. # -create table t1 (a text) engine=innodb; +create table t2 (a text) engine=innodb; start transaction; -insert t1 select repeat(seq, 1000) from seq_1_to_15; +insert t2 select repeat(seq, 1000) from seq_1_to_15; savepoint foo; -insert t1 select repeat(seq, 1000) from seq_16_to_30; +insert t2 select repeat(seq, 1000) from seq_16_to_30; rollback to savepoint foo; -insert t1 select repeat(seq, 1000) from seq_31_to_40; +insert t2 select repeat(seq, 1000) from seq_31_to_40; commit; -drop table t1; disconnect con2; connection default; +flush binary logs; + +drop table t1, t2; + set global binlog_cache_size=default; + +let $MYSQLD_DATADIR= `select @@datadir`; +exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL; + +select left(a, 10) from t1; +select left(a, 10) from t2; +drop table t1, t2; diff --git a/mysql-test/suite/federated/have_federatedx.inc b/mysql-test/suite/federated/have_federatedx.inc index 56ce31f5b2fdc7d57e76b0215625826113346d6f..2250dd205bdca8475be276bfc50b0d72524643c7 100644 --- a/mysql-test/suite/federated/have_federatedx.inc +++ b/mysql-test/suite/federated/have_federatedx.inc @@ -1,5 +1,5 @@ if (!`SELECT count(*) FROM information_schema.plugins WHERE plugin_name = 'federated' AND plugin_status = 'active' AND - plugin_description LIKE '%FederatedX%'`){ + plugin_description LIKE '%transactions%'`){ skip Need FederatedX engine; } diff --git a/mysql-test/suite/funcs_1/r/is_engines_archive.result b/mysql-test/suite/funcs_1/r/is_engines_archive.result index 2772992495c54bb491507271484f719fa42cebd6..52802b17acd8196d236f5931a2e5b1ea1ac87bf6 100644 --- a/mysql-test/suite/funcs_1/r/is_engines_archive.result +++ b/mysql-test/suite/funcs_1/r/is_engines_archive.result @@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines WHERE ENGINE = 'ARCHIVE'; ENGINE ARCHIVE SUPPORT YES -COMMENT Archive storage engine +COMMENT gzip-compresses tables for a low storage footprint TRANSACTIONS NO XA NO SAVEPOINTS NO diff --git a/mysql-test/suite/funcs_1/r/is_engines_csv.result b/mysql-test/suite/funcs_1/r/is_engines_csv.result index 2a7e61ee4d3cb76453baff9e9e4ae35826e20785..7e413b9af6f28924bebd4f133ebcce044af363ac 100644 --- a/mysql-test/suite/funcs_1/r/is_engines_csv.result +++ b/mysql-test/suite/funcs_1/r/is_engines_csv.result @@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines WHERE ENGINE = 'CSV'; ENGINE CSV SUPPORT YES -COMMENT CSV storage engine +COMMENT Stores tables as CSV files TRANSACTIONS NO XA NO SAVEPOINTS NO diff --git a/mysql-test/suite/funcs_1/r/is_engines_federated.result b/mysql-test/suite/funcs_1/r/is_engines_federated.result index 8057a0266c574b39e0f7d2733fe96306b611c4ce..20926458ed00f65486232f5e9d47f9fbff8dee25 100644 --- a/mysql-test/suite/funcs_1/r/is_engines_federated.result +++ b/mysql-test/suite/funcs_1/r/is_engines_federated.result @@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines WHERE ENGINE = 'FEDERATED'; ENGINE FEDERATED SUPPORT YES -COMMENT FederatedX pluggable storage engine +COMMENT Allows to access tables on other MariaDB servers, supports transactions and more TRANSACTIONS YES XA NO SAVEPOINTS YES diff --git a/mysql-test/suite/funcs_1/r/is_engines_myisam.result b/mysql-test/suite/funcs_1/r/is_engines_myisam.result index 7e42c864187da40bac3b5e627b97667df59505ab..d307ce4be6a006011c62cff7d68cc92404e9b1f1 100644 --- a/mysql-test/suite/funcs_1/r/is_engines_myisam.result +++ b/mysql-test/suite/funcs_1/r/is_engines_myisam.result @@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines WHERE ENGINE = 'MyISAM'; ENGINE MyISAM SUPPORT DEFAULT -COMMENT MyISAM storage engine +COMMENT Non-transactional engine with good performance and small data footprint TRANSACTIONS NO XA NO SAVEPOINTS NO diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index b67dea0f2f4c5718a9399bc201550006cf65d308..397ad22dab8b684daa0aff7b532a1f3adcf2286c 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -9,53 +9,24 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -MW-336 : MDEV-13549 Galera test failures -galera_gra_log : MDEV-13549 Galera test failures -galera_flush_local : MDEV-13549 Galera test failures -galera_flush : MDEV-13549 Galera test failures -MW-329 : MDEV-13549 Galera test failures + +galera_flush : MariaDB does not have global.thread_statistics galera_account_management : MariaDB 10.0 does not support ALTER USER -galera_binlog_row_image : MariaDB 10.0 does not support binlog_row_image galera_binlog_rows_query_log_events: MariaDB does not support binlog_rows_query_log_events -GAL-419 : MDEV-13549 Galera test failures -galera_toi_ddl_fk_insert : MDEV-13549 Galera test failures -galera_var_notify_cmd : MDEV-13549 Galera test failures -galera_var_slave_threads : MDEV-13549 Galera test failures -mysql-wsrep#90 : MDEV-13549 Galera test failures +galera_migrate : MariaDB does not support START SLAVE USER galera_as_master_gtid : Requires MySQL GTID galera_as_master_gtid_change_master : Requires MySQL GTID -galera_as_slave_replication_bundle : MDEV-13549 Galera test failures galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB -galera_gcs_fragment : MDEV-13549 Galera test failures +GAL-419 : MDEV-13549 Galera test failures +galera_var_notify_cmd : MDEV-13549 Galera test failures +galera_as_slave_replication_bundle : MDEV-13549 Galera test failures galera_gcache_recover : MDEV-13549 Galera test failures galera_gcache_recover_full_gcache : MDEV-13549 Galera test failures galera_gcache_recover_manytrx : MDEV-13549 Galera test failures -galera_ist_mysqldump : MDEV-13549 Galera test failures -mysql-wsrep#31 : MDEV-13549 Galera test failures -galera_migrate : MariaDB 10.0 does not support START SLAVE USER -galera_concurrent_ctas : MDEV-13549 Galera test failures -galera_bf_abort_for_update : MDEV-13549 Galera test failures -galera_wsrep_desync_wsrep_on : MDEV-13549 Galera test failures galera_ssl_upgrade : MDEV-13549 Galera test failures -mysql-wsrep#33 : MDEV-13549 Galera test failures -galera_var_auto_inc_control_on : MDEV-13549 Galera test failures -MW-44 : MDEV-13549 Galera test failures -galera_var_retry_autocommit : MDEV-13549 Galera test failures -pxc-421 : MDEV-13549 Galera test failures -lp1376747-2 : MDEV-13549 Galera test failures -lp1376747 : MDEV-13549 Galera test failures -galera_toi_ddl_nonconflicting : MDEV-13549 Galera test failures -galera_parallel_simple : MDEV-13549 Galera test failures -galera_admin : MDEV-13549 Galera test failures -galera_var_max_ws_rows : MDEV-13549 Galera test failures 10.1 -MW-286 : MDEV-13549 Galera test failures 10.1 -galera_as_master: MDEV-13549 Galera test failures 10.1 -galera_pc_ignore_sb : MDEV-13549 Galera test failures 10.1 -galera_lock_table : MDEV-13549 Galera test failures 10.1 -MW-284 : MDEV-13549 Galera test failures 10.1 -galera_as_slave : MDEV-13549 Galera test failures 10.1 -MW-328C: MDEV-13549 Galera test failures 10.1 -MW-328A: MDEV-13549 Galera test failures 10.1 -MW-328B: MDEV-13549 Galera test failures 10.1 -MW-328: MDEV-13549 Galera test failures 10.1 -galera_suspend_slave: MDEV-13549 Galera test failures 10.1 \ No newline at end of file +galera.MW-329 : wsrep_local_replays not stable +galera.MW-328A : have_deadlocks test not stable +query_cache : MDEV-15805 Test failure on galera.query_cache +MW-416 : MDEV-13549 Galera test failures +galera_wan : MDEV-13549 Galera test failures +MW-388 : MDEV-13549 Galera test failures diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf deleted file mode 100644 index f68fe5249044de14eac065cf54834d99b67506b5..0000000000000000000000000000000000000000 --- a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf +++ /dev/null @@ -1,83 +0,0 @@ - -# -# Let's understand the topology. -# * Independent Master with server-id = 1 -# * Galera cluster with 2 nodes: node#1 and node#2 with server-id = 2, 3 -# node#1 act as slave to Independent Master with server-id = 1 -# * Independent Slave with server-id = 4 replicating from galera node#2 -# - -# Use default setting for mysqld processes -!include include/default_mysqld.cnf - -[mysqld] -log-slave-updates -log-bin=mysqld-bin -binlog-format=row -gtid-mode=on -enforce-gtid-consistency=true - -[mysqld.1] -server-id=1 - -[mysqld.2] -server-id=2 - -wsrep_provider=@ENV.WSREP_PROVIDER -wsrep_cluster_address='gcomm://' -wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;' - -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON -wsrep_sync_wait = 15 - -wsrep_node_address=127.0.0.1 -wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port -wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port - -# Required for Galera -innodb_autoinc_lock_mode=2 - -innodb_flush_log_at_trx_commit=2 - -[mysqld.3] -server-id=3 - -wsrep_provider=@ENV.WSREP_PROVIDER -wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port' -wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;' - -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON -wsrep_sync_wait = 15 - -wsrep_node_address=127.0.0.1 -wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port -wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port - -# Required for Galera -innodb_autoinc_lock_mode=2 - -innodb_flush_log_at_trx_commit=2 - -[mysqld.4] -server-id=4 - -[ENV] -NODE_MYPORT_1= @mysqld.1.port -NODE_MYSOCK_1= @mysqld.1.socket - -NODE_MYPORT_2= @mysqld.2.port -NODE_MYSOCK_2= @mysqld.2.socket - -NODE_MYPORT_3= @mysqld.3.port -NODE_MYSOCK_3= @mysqld.3.socket - -NODE_MYPORT_4= @mysqld.4.port -NODE_MYSOCK_4= @mysqld.4.socket - -NODE_GALERAPORT_2= @mysqld.2.#galera_port -NODE_GALERAPORT_3= @mysqld.3.#galera_port - -NODE_SSTPORT_2= @mysqld.2.#sst_port -NODE_SSTPORT_3= @mysqld.3.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf deleted file mode 100644 index d5490280ab24dc124348c3c16c82eedb0a6fef43..0000000000000000000000000000000000000000 --- a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf +++ /dev/null @@ -1,87 +0,0 @@ -# -# This .cnf file creates a setup with a 2-node Galera cluster and one stand-alone MySQL server, to be used as a slave -# - -# Use default setting for mysqld processes -!include include/default_mysqld.cnf - -[mysqld] -default-storage-engine=InnoDB - -[mysqld.1] -server-id=1 -binlog-format=row -log-bin=mysqld-bin -log_slave_updates -gtid-mode=on -enforce-gtid-consistency=true -event-scheduler=1 - -wsrep_provider=@ENV.WSREP_PROVIDER -wsrep_cluster_address='gcomm://' -wsrep_provider_options='base_port=@mysqld.1.#galera_port' - -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON -wsrep_sync_wait = 15 - -wsrep_node_address=127.0.0.1 -wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port -wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port - -# Required for Galera -innodb_autoinc_lock_mode=2 - -innodb_flush_log_at_trx_commit=2 - -[mysqld.2] -server-id=2 -binlog-format=row -log-bin=mysqld-bin -log_slave_updates -gtid-mode=on -enforce-gtid-consistency=true -event-scheduler=1 - -wsrep_provider=@ENV.WSREP_PROVIDER -wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' -wsrep_provider_options='base_port=@mysqld.2.#galera_port' - -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON -wsrep_sync_wait = 15 - -wsrep_node_address=127.0.0.1 -wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port -wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port - -# Required for Galera -innodb_autoinc_lock_mode=2 - -innodb_flush_log_at_trx_commit=2 - -[mysqld.3] -server-id=3 -replicate-ignore-db=test -replicate-wild-ignore-table=test.% -log-bin=mysqld-bin -log_slave_updates -gtid-mode=on -enforce-gtid-consistency=true -event-scheduler=1 - -[ENV] -NODE_MYPORT_1= @mysqld.1.port -NODE_MYSOCK_1= @mysqld.1.socket - -NODE_MYPORT_2= @mysqld.2.port -NODE_MYSOCK_2= @mysqld.2.socket - -NODE_MYPORT_3= @mysqld.3.port -NODE_MYSOCK_3= @mysqld.3.socket - -NODE_GALERAPORT_1= @mysqld.1.#galera_port -NODE_GALERAPORT_2= @mysqld.2.#galera_port - -NODE_SSTPORT_1= @mysqld.1.#sst_port -NODE_SSTPORT_2= @mysqld.2.#sst_port diff --git a/mysql-test/suite/galera/include/galera_load_provider.inc b/mysql-test/suite/galera/include/galera_load_provider.inc index 761a1a89fd38dfd1a1c684a1b5104ef6fb9cfc73..aeab7e6ea199f099b805634c7393abd3ff285493 100644 --- a/mysql-test/suite/galera/include/galera_load_provider.inc +++ b/mysql-test/suite/galera/include/galera_load_provider.inc @@ -5,6 +5,4 @@ --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log ---enable_reconnect ---source include/wait_until_connected_again.inc ---source include/wait_until_ready.inc +--source include/galera_wait_ready.inc diff --git a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc index cbd2c1c817ad07241b9ecb2aa9428f01b759814c..16af5742b9b9f80b2668badec0d2a607f667118f 100644 --- a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc +++ b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc @@ -4,6 +4,9 @@ --echo Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); + --connection node_1 # We need a user with a password to perform SST, otherwise we hit LP #1378253 CREATE USER 'sst'; @@ -19,6 +22,6 @@ SET GLOBAL wsrep_sst_auth = 'sst:'; --disable_query_log # Set wsrep_sst_receive_address to the SQL port ---eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.2:$NODE_MYPORT_2'; +--eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.1:$NODE_MYPORT_2'; --enable_query_log SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/include/galera_st_clean_slave.inc b/mysql-test/suite/galera/include/galera_st_clean_slave.inc index 81ba54aa6f5b2f7eddcb6388477279e1bd2e98d5..3a49f4f6ad2e84731cd55e853cfe5ef1a90e382b 100644 --- a/mysql-test/suite/galera/include/galera_st_clean_slave.inc +++ b/mysql-test/suite/galera/include/galera_st_clean_slave.inc @@ -64,7 +64,9 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); --connection node_2 --echo Starting server ... --source include/start_mysqld.inc ---source include/wait_until_ready.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc SET AUTOCOMMIT=OFF; START TRANSACTION; diff --git a/mysql-test/suite/galera/include/galera_st_kill_slave.inc b/mysql-test/suite/galera/include/galera_st_kill_slave.inc index bae37755c65f23be27fa6a00ed02dfd36ad315aa..0b96de55a32ddc324464ed74faa8de5f4e817825 100644 --- a/mysql-test/suite/galera/include/galera_st_kill_slave.inc +++ b/mysql-test/suite/galera/include/galera_st_kill_slave.inc @@ -24,7 +24,6 @@ COMMIT; --source include/kill_galera.inc --connection node_1 ---source include/wait_until_connected_again.inc --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' --source include/wait_condition.inc @@ -59,7 +58,9 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); --echo Starting server ... --source include/start_mysqld.inc ---source include/wait_until_ready.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc SET AUTOCOMMIT=OFF; START TRANSACTION; diff --git a/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc b/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc index b8dd0fda987b16692e3cfb283e7b79f1c9ee7c8a..44a1513fa6e2e1e093f723886de67c5f1225e012 100644 --- a/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc +++ b/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc @@ -1,3 +1,5 @@ +source include/maybe_debug.inc; +if ($have_debug) { --echo Performing State Transfer on a server that has been killed and restarted --echo while a DDL was in progress on it @@ -70,7 +72,9 @@ INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); --connection node_2 --echo Starting server ... --source include/start_mysqld.inc ---source include/wait_until_ready.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc SET AUTOCOMMIT=OFF; START TRANSACTION; @@ -121,3 +125,4 @@ COMMIT; SET AUTOCOMMIT=ON; SET GLOBAL debug_dbug = $debug_orig; +} diff --git a/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc index 1a65ef1bd942aa27ac8de52d980f0915cb79b55c..6c09b0ceb0c770105eb7de78a94528b06d2211a6 100644 --- a/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc +++ b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc @@ -56,7 +56,9 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); --connection node_2 --echo Starting server ... --source include/start_mysqld.inc ---source include/wait_until_ready.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc SET AUTOCOMMIT=OFF; START TRANSACTION; diff --git a/mysql-test/suite/galera/include/have_mariabackup.inc b/mysql-test/suite/galera/include/have_mariabackup.inc new file mode 100644 index 0000000000000000000000000000000000000000..0dd693f2c6399c451cb24bd4737777da0c39caed --- /dev/null +++ b/mysql-test/suite/galera/include/have_mariabackup.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped as needed +# diff --git a/mysql-test/suite/galera/include/have_wsrep_replicate_myisam.inc b/mysql-test/suite/galera/include/have_wsrep_replicate_myisam.inc new file mode 100644 index 0000000000000000000000000000000000000000..726fc6e2b1882d476b1731df40cbf0f80416ed08 --- /dev/null +++ b/mysql-test/suite/galera/include/have_wsrep_replicate_myisam.inc @@ -0,0 +1,4 @@ +--require suite/galera/r/have_wsrep_replicate_myisam.require +disable_query_log; +SHOW VARIABLES LIKE 'wsrep_replicate_myisam'; +enable_query_log; diff --git a/mysql-test/suite/galera/include/have_xtrabackup.inc b/mysql-test/suite/galera/include/have_xtrabackup.inc new file mode 100644 index 0000000000000000000000000000000000000000..0dd693f2c6399c451cb24bd4737777da0c39caed --- /dev/null +++ b/mysql-test/suite/galera/include/have_xtrabackup.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped as needed +# diff --git a/mysql-test/suite/galera/include/kill_galera.inc b/mysql-test/suite/galera/include/kill_galera.inc index c61bad8e19d3aa374eeebaf1930b33aa1dce44bc..d7f665df6c750c610c19f7125bf70cd96901b23e 100644 --- a/mysql-test/suite/galera/include/kill_galera.inc +++ b/mysql-test/suite/galera/include/kill_galera.inc @@ -1,7 +1,6 @@ --echo Killing server ... # Write file to make mysql-test-run.pl expect the crash, but don't start it ---source include/wait_until_connected_again.inc --let $_server_id= `SELECT @@server_id` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect --exec echo "wait" > $_expect_file_name diff --git a/mysql-test/suite/galera/include/start_mysqld.inc b/mysql-test/suite/galera/include/start_mysqld.inc index 4ee3d17810cbb15e8f6b01efbfea0300e714981b..57af9203d0f6bec76511d56c8c82bdc3daa7fd83 100644 --- a/mysql-test/suite/galera/include/start_mysqld.inc +++ b/mysql-test/suite/galera/include/start_mysqld.inc @@ -12,11 +12,4 @@ if ($galera_wsrep_start_position == '') { --exec echo "restart:$start_mysqld_params" > $_expect_file_name } -# Turn on reconnect ---enable_reconnect - -# Call script that will poll the server waiting for it to be back online again ---source include/wait_until_connected_again.inc - -# Turn off reconnect again ---disable_reconnect +--source include/galera_wait_ready.inc diff --git a/mysql-test/suite/galera/r/MW-284.result b/mysql-test/suite/galera/r/MW-284.result index 9d1c3e5660d826d08888107e7f1551fae43ab253..c9c0069889b636958567941660a111c57a1eb486 100644 --- a/mysql-test/suite/galera/r/MW-284.result +++ b/mysql-test/suite/galera/r/MW-284.result @@ -14,3 +14,6 @@ STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression('failed registering on master'); CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); +RESET MASTER; +CALL mtr.add_suppression('WSREP: Last Applied Action message in non-primary configuration from member'); +CALL mtr.add_suppression('WSREP: Last Applied Action message in non-primary configuration from member'); diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result index a79ba598d69a158fdd4a9685e99b0b638bff1a49..4666d131c7dddb7f57428c90df27a014e644bae9 100644 --- a/mysql-test/suite/galera/r/MW-329.result +++ b/mysql-test/suite/galera/r/MW-329.result @@ -19,3 +19,4 @@ VARIABLE_VALUE > 0 DROP PROCEDURE proc_insert; DROP TABLE t1; CALL mtr.add_suppression("conflict state 3 after post commit"); +set global innodb_status_output=Default; diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result index 9bdb61c1a9c93513498c8dc905480bfc7c2fb468..34874198c6f925facae0c0ec797b3a82fbba0ef7 100644 --- a/mysql-test/suite/galera/r/MW-336.result +++ b/mysql-test/suite/galera/r/MW-336.result @@ -3,13 +3,7 @@ SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 1; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_slave_threads = 10; -SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; -COUNT(*) = 11 -1 SET GLOBAL wsrep_slave_threads = 20; -SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; -COUNT(*) = 21 -1 SET GLOBAL wsrep_slave_threads = 1; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); @@ -35,8 +29,5 @@ INSERT INTO t1 VALUES (17); INSERT INTO t1 VALUES (18); INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (20); -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; -COUNT(*) = 2 -1 SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/MW-416.result b/mysql-test/suite/galera/r/MW-416.result new file mode 100644 index 0000000000000000000000000000000000000000..05399b213a83794f64b2bf549e8351cb4b1d2ecc --- /dev/null +++ b/mysql-test/suite/galera/r/MW-416.result @@ -0,0 +1,114 @@ +CREATE USER 'userMW416'@'localhost'; +GRANT SELECT, INSERT, UPDATE ON test.* TO 'userMW416'@'localhost'; +SHOW GLOBAL STATUS LIKE 'wsrep_replicated'; +Variable_name Value +wsrep_replicated 2 +ALTER DATABASE db CHARACTER SET = utf8; +ERROR 42000: Access denied for user 'userMW416'@'localhost' to database 'db' +ALTER EVENT ev1 RENAME TO ev2; +ERROR 42000: Access denied for user 'userMW416'@'localhost' to database 'test' +ALTER FUNCTION fun1 COMMENT 'foo'; +ERROR 42000: alter routine command denied to user 'userMW416'@'localhost' for routine 'test.fun1' +ALTER LOGFILE GROUP lfg ADD UNDOFILE 'file' ENGINE=InnoDB; +Got one of the listed errors +ALTER PROCEDURE proc1 COMMENT 'foo'; +Got one of the listed errors +ALTER SERVER srv OPTIONS (USER 'sally'); +Got one of the listed errors +ALTER TABLE tbl DROP COLUMN col; +Got one of the listed errors +ALTER TABLESPACE tblspc DROP DATAFILE 'file' ENGINE=innodb; +Got one of the listed errors +ALTER VIEW vw AS SELECT 1; +Got one of the listed errors +CREATE DATABASE db; +Got one of the listed errors +CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO SELECT 1; +Got one of the listed errors +CREATE FUNCTION fun1() RETURNS int RETURN(1); +Got one of the listed errors +CREATE FUNCTION fun1 RETURNS STRING SONAME 'funlib.so'; +Got one of the listed errors +CREATE PROCEDURE proc1() BEGIN END; +Got one of the listed errors +CREATE INDEX idx ON tbl(id); +Got one of the listed errors +CREATE LOGFILE GROUP lfg ADD UNDOFILE 'undofile' ENGINE innodb; +Got one of the listed errors +CREATE SERVER srv FOREIGN DATA WRAPPER 'fdw' OPTIONS (USER 'user'); +Got one of the listed errors +CREATE TABLE t (i int); +Got one of the listed errors +CREATE TABLESPACE tblspc ADD DATAFILE 'file' ENGINE=innodb; +Got one of the listed errors +CREATE TRIGGER trg BEFORE UPDATE ON t FOR EACH ROW BEGIN END; +Got one of the listed errors +CREATE VIEW vw AS SELECT 1; +Got one of the listed errors +DROP DATABASE db; +Got one of the listed errors +DROP EVENT ev; +Got one of the listed errors +DROP FUNCTION fun1; +Got one of the listed errors +DROP INDEX idx ON t0; +Got one of the listed errors +DROP LOGFILE GROUP lfg; +Got one of the listed errors +DROP PROCEDURE proc1; +Got one of the listed errors +DROP SERVEr srv; +Got one of the listed errors +DROP TABLE t0; +Got one of the listed errors +DROP TABLESPACE tblspc; +Got one of the listed errors +DROP TRIGGER trg; +Got one of the listed errors +DROP VIEW vw; +Got one of the listed errors +RENAME TABLE t0 TO t1; +Got one of the listed errors +TRUNCATE TABLE t0; +Got one of the listed errors +ALTER USER myuser PASSWORD EXPIRE; +Got one of the listed errors +CREATE USER myuser IDENTIFIED BY 'pass'; +Got one of the listed errors +DROP USER myuser; +Got one of the listed errors +GRANT ALL ON *.* TO 'myuser'; +Got one of the listed errors +RENAME USER myuser TO mariauser; +Got one of the listed errors +REVOKE SELECT ON test FROM myuser; +Got one of the listed errors +REVOKE ALL, GRANT OPTION FROM myuser; +Got one of the listed errors +REVOKE PROXY ON myuser FROM myuser; +Got one of the listed errors +ANALYZE TABLE db.tbl; +Got one of the listed errors +CHECK TABLE db.tbl; +Got one of the listed errors +CHECKSUM TABLE db.tbl; +Got one of the listed errors +OPTIMIZE TABLE db.tbl; +Got one of the listed errors +REPAIR TABLE db.tbl; +Got one of the listed errors +INSTALL PLUGIN plg SONAME 'plg.so'; +Got one of the listed errors +UNINSTALL PLUGIN plg; +Got one of the listed errors +DROP USER 'userMW416'@'localhost'; +SHOW DATABASES; +Database +information_schema +mtr +mysql +performance_schema +test +SHOW GLOBAL STATUS LIKE 'wsrep_replicated'; +Variable_name Value +wsrep_replicated 3 diff --git a/mysql-test/suite/galera/r/MW-44.result b/mysql-test/suite/galera/r/MW-44.result index 28a6f1ac8dd23c0d1f0584d33daa9cc3f29e54d3..459a61030a4868b7e9adece18936d792f8870630 100644 --- a/mysql-test/suite/galera/r/MW-44.result +++ b/mysql-test/suite/galera/r/MW-44.result @@ -1,5 +1,21 @@ +SET GLOBAL general_log='OFF'; TRUNCATE TABLE mysql.general_log; +SELECT COUNT(*) from mysql.general_log; +COUNT(*) +0 +SELECT * FROM mysql.general_log; +event_time user_host thread_id server_id command_type argument +SET GLOBAL general_log='OFF'; TRUNCATE TABLE mysql.general_log; +SELECT COUNT(*) from mysql.general_log; +COUNT(*) +0 +SELECT * FROM mysql.general_log; +event_time user_host thread_id server_id command_type argument +SET GLOBAL general_log='ON'; +SELECT COUNT(*) from mysql.general_log; +COUNT(*) +1 SET SESSION wsrep_osu_method=TOI; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; SET SESSION wsrep_osu_method=RSU; @@ -8,6 +24,7 @@ SET SESSION wsrep_osu_method=TOI; SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; COUNT(*) = 2 1 +SET GLOBAL general_log='ON'; SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; COUNT(*) = 0 1 diff --git a/mysql-test/suite/galera/r/galera#500.result b/mysql-test/suite/galera/r/galera#500.result new file mode 100644 index 0000000000000000000000000000000000000000..6a07d0359a46df2ea03ae73e8d7a20d18add9113 --- /dev/null +++ b/mysql-test/suite/galera/r/galera#500.result @@ -0,0 +1,10 @@ +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options="gmcast.isolate=2"; +SET SESSION wsrep_sync_wait = 0; +SHOW STATUS LIKE 'wsrep_cluster_status'; +Variable_name Value +wsrep_cluster_status non-Primary +SET SESSION wsrep_sync_wait = default; +SET GLOBAL wsrep_provider_options="pc.bootstrap=1"; +SET SESSION wsrep_on=0; +CALL mtr.add_suppression("WSREP: exception from gcomm, backend must be restarted: Gcomm backend termination was requested by setting gmcast.isolate=2."); diff --git a/mysql-test/suite/galera/r/galera_as_master.result b/mysql-test/suite/galera/r/galera_as_master.result index e96d39aea0cbbceb5d29b59de51557e80ba11908..06de9ccf016b35728dab2efff6b7e8cccb201ce9 100644 --- a/mysql-test/suite/galera/r/galera_as_master.result +++ b/mysql-test/suite/galera/r/galera_as_master.result @@ -47,3 +47,4 @@ DROP TABLE t2, t3; STOP SLAVE; RESET SLAVE ALL; CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); +RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_for_update.result b/mysql-test/suite/galera/r/galera_bf_abort_for_update.result index 3978a3df193f811481531e9814f561a386c66569..2367924466c4d0737dedb3e86be658eed01ef647 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_for_update.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_for_update.result @@ -1,10 +1,21 @@ -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (1); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 10); +BEGIN; SELECT * FROM t1 FOR UPDATE; +f1 f2 +1 10 +UPDATE t1 SET f1 = 2; +COMMIT; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -wsrep_local_aborts_increment +wsrep_local_bf_aborts_diff +1 +BEGIN; +SELECT * FROM t1 FOR UPDATE; +f1 f2 +2 10 +UPDATE t1 SET f2 = 20; +COMMIT; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +wsrep_local_bf_aborts_diff 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 28c3f4dd1044585c209ecc32fe79118f081c2549..5c5fdabf432d3fe966f6691e767ecfd5d3832892 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -1,6 +1,6 @@ SELECT COUNT(*) = 43 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'wsrep_%'; COUNT(*) = 43 -1 +0 SELECT VARIABLE_NAME, VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'wsrep_%' @@ -40,6 +40,7 @@ WSREP_NOTIFY_CMD WSREP_ON ON WSREP_OSU_METHOD TOI WSREP_RECOVER OFF +WSREP_REJECT_QUERIES NONE WSREP_REPLICATE_MYISAM OFF WSREP_RESTART_SLAVE OFF WSREP_RETRY_AUTOCOMMIT 1 @@ -51,7 +52,7 @@ WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync WSREP_SYNC_WAIT 15 -; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +; ; ; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; ; gcache.keep_pages_size = 0; gcache.mem_size = 0; ; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; ; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; ; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; ;socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera/r/galera_encrypt_tmp_files.result b/mysql-test/suite/galera/r/galera_encrypt_tmp_files.result new file mode 100644 index 0000000000000000000000000000000000000000..63f6c281af14a65bfe998524278150caf2afeec7 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_encrypt_tmp_files.result @@ -0,0 +1,35 @@ +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE = 'Synced' +1 +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 VALUES (1); +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE = 'Synced' +1 +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; +CREATE TABLE `t1` ( +`col1` int(11) NOT NULL, +`col2` varchar(64) NOT NULL DEFAULT '', +`col3` varchar(32) NOT NULL DEFAULT '0', +`col4` varchar(64) NOT NULL DEFAULT '', +`col5` tinyint(4) NOT NULL DEFAULT '0', +`col6` int(11) NOT NULL DEFAULT '0', +`col7` varchar(64) NOT NULL DEFAULT '', +`col8` tinyint(4) NOT NULL DEFAULT '0', +`col9` tinyint(4) NOT NULL DEFAULT '0', +`col10` text NOT NULL, +`col11` varchar(255) NOT NULL DEFAULT '', +`col12` tinyint(4) NOT NULL DEFAULT '1' +) ; +create table t2 (test int); +insert into t2 values (1); +drop table t1,t2; diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result index 9f5cbdd75fccfcf57a73b4a5a71d667e9f8603d0..a5b87c0ef0c799cf3c3b8c60d0447f4f8df47454 100644 --- a/mysql-test/suite/galera/r/galera_gra_log.result +++ b/mysql-test/suite/galera/r/galera_gra_log.result @@ -1,6 +1,7 @@ SET SESSION wsrep_on=OFF; CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t1 (f1 INTEGER); +SET SESSION wsrep_on=ON; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 @@ -8,22 +9,13 @@ COUNT(*) = 0 /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; -# at 4 - server id 2 end_log_pos 120 Start: binlog v 4, server v 5.6.24-debug-log created 150804 11:37:14 at startup -# Warning: this binlog is either in use or was not closed properly. ROLLBACK/*!*/; -BINLOG ' -unnAVQ8CAAAAdAAAAHgAAAABAAQANS42LjI0LWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAC6ecBVEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAKNu -Jfk= -'/*!*/; -# at 120 - server id 1 end_log_pos 91 Query thread_id= exec_time=0 error_code=0 +ROLLBACK/*!*/; use `test`/*!*/; SET TIMESTAMP=/*!*/; SET @@session.pseudo_thread_id=/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; +SET @@session.sql_mode=1342177280/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; @@ -36,6 +28,5 @@ DELIMITER ; ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; -SET SESSION wsrep_on=ON; CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query"); DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_gtid_slave.result b/mysql-test/suite/galera/r/galera_gtid_slave.result index 40f3f1c0d53fb41902d4d15cb61a9622cdf9eed0..58a9d3f5971824101ce523a1f70f3861076a1f44 100644 --- a/mysql-test/suite/galera/r/galera_gtid_slave.result +++ b/mysql-test/suite/galera/r/galera_gtid_slave.result @@ -19,8 +19,8 @@ SELECT @@global.gtid_binlog_state; @@global.gtid_binlog_state 1-1-4,2-2-2,2-3-3 DROP TABLE t1,t2; -reset master; STOP SLAVE; RESET SLAVE ALL; reset master; reset master; +reset master; diff --git a/mysql-test/suite/galera/r/galera_ist_mysqldump.result b/mysql-test/suite/galera/r/galera_ist_mysqldump.result index 788d60051b54a1ce3ebea01c2835d82b1123aeaa..a7ce7c6c23e5b89d246e5acd7832f89a144a3b7d 100644 --- a/mysql-test/suite/galera/r/galera_ist_mysqldump.result +++ b/mysql-test/suite/galera/r/galera_ist_mysqldump.result @@ -1,4 +1,6 @@ Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; @@ -194,7 +196,7 @@ INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); COMMIT; -SET GLOBAL debug = 'd,sync.alter_opened_table'; +SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SET wsrep_sync_wait = 0; Killing server ... @@ -273,6 +275,7 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; +SET GLOBAL debug_dbug = $debug_orig; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); DROP USER sst; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); diff --git a/mysql-test/suite/galera/r/galera_kill_nochanges.result b/mysql-test/suite/galera/r/galera_kill_nochanges.result index db3c75e288634745cec918909b7a2d8d13990a38..cdcebdb4eeea281d8b29cd986490f46d3e782ca5 100644 --- a/mysql-test/suite/galera/r/galera_kill_nochanges.result +++ b/mysql-test/suite/galera/r/galera_kill_nochanges.result @@ -1,6 +1,8 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); Killing server ... +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_sync_wait = DEFAULT; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_lock_table.result b/mysql-test/suite/galera/r/galera_lock_table.result index 16e9037a4de77d05c62df2f2e1920e54c018dd7d..0d40ac1656545509b47732bc50da2617dc3e24e1 100644 --- a/mysql-test/suite/galera/r/galera_lock_table.result +++ b/mysql-test/suite/galera/r/galera_lock_table.result @@ -1,5 +1,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +NAME +test/t1 +test/t2 LOCK TABLE t1 READ; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); diff --git a/mysql-test/suite/galera/r/galera_mdev_15611.result b/mysql-test/suite/galera/r/galera_mdev_15611.result new file mode 100644 index 0000000000000000000000000000000000000000..677ed98202d4be034ae40aca36e31a8149366714 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_mdev_15611.result @@ -0,0 +1,15 @@ +CREATE TABLE t1 ( +id int primary key +); +CREATE TABLE t2 ( +id int primary key , +f_id int DEFAULT NULL, FOREIGN KEY(f_id) REFERENCES t1 (id) +); +insert into t1 select 1; +#Running 200 insert in t2 table +select count(*) from t2; +count(*) +200 +delete from t2; +delete from t1; +drop table t2,t1; diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result index 3b10815c63d295cf57395e382b363719527842c6..0b19ef7da8f6c8c2e94c01e87b4b4b6ef6b21788 100644 --- a/mysql-test/suite/galera/r/galera_parallel_simple.result +++ b/mysql-test/suite/galera/r/galera_parallel_simple.result @@ -1,6 +1,10 @@ CREATE TABLE t1 (id INT) ENGINE=InnoDB; CREATE TABLE t2 (id INT) ENGINE=InnoDB; SET GLOBAL wsrep_slave_threads = 2; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +NAME +test/t1 +test/t2 LOCK TABLE t1 WRITE; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); diff --git a/mysql-test/suite/galera/r/galera_schema_dirty_reads.result b/mysql-test/suite/galera/r/galera_schema_dirty_reads.result new file mode 100644 index 0000000000000000000000000000000000000000..edf20da92c63e4afc90bd1f6a948fa41e239b695 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_schema_dirty_reads.result @@ -0,0 +1,13 @@ +USE information_schema; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; +VARIABLE_NAME VARIABLE_VALUE +WSREP_DIRTY_READS OFF +SET GLOBAL wsrep_reject_queries=ALL; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; +VARIABLE_NAME VARIABLE_VALUE +WSREP_DIRTY_READS OFF +SET GLOBAL wsrep_reject_queries=NONE; +SET SESSION wsrep_dirty_reads=TRUE; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; +VARIABLE_NAME VARIABLE_VALUE +WSREP_DIRTY_READS ON diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..efedb1b469a9a6562155d204ce41173155c13219 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff @@ -0,0 +1,103 @@ +--- galera_sst_mariabackup.reject ++++ galera_sst_mariabackup.result +@@ -260,3 +260,100 @@ + DROP TABLE t1; + COMMIT; + SET AUTOCOMMIT=ON; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++SET wsrep_sync_wait = 0; ++Killing server ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++Performing --wsrep-recover ... ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++ROLLBACK; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++SET AUTOCOMMIT=ON; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET AUTOCOMMIT=ON; ++SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup.result b/mysql-test/suite/galera/r/galera_sst_mariabackup.result new file mode 100644 index 0000000000000000000000000000000000000000..cec0f21ee22ae6c29957854a1aee7dc0d7da8cfc --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup.result @@ -0,0 +1,262 @@ +Performing State Transfer on a server that has been shut down cleanly and restarted +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that starts from a clean var directory +This is accomplished by shutting down node #2 and removing its var directory before restarting it +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +Cleaning var directory ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that has been killed and restarted +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Killing server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +Performing --wsrep-recover ... +Starting server ... +Using --wsrep-start-position when starting mysqld ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_mysqldump,debug.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..a7ed54af860e8fe0bee1c9859105e9d2eced9ffa --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump,debug.rdiff @@ -0,0 +1,106 @@ +--- galera_sst_mysqldump.reject ++++ galera_sst_mysqldump.result +@@ -354,6 +354,103 @@ + DROP TABLE t1; + COMMIT; + SET AUTOCOMMIT=ON; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++SET wsrep_sync_wait = 0; ++Killing server ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++Performing --wsrep-recover ... ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++ROLLBACK; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++SET AUTOCOMMIT=ON; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET AUTOCOMMIT=ON; ++SET GLOBAL debug_dbug = $debug_orig; + CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); + DROP USER sst; + CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump.result b/mysql-test/suite/galera/r/galera_sst_mysqldump.result index 5c0d9a45d41fab3920282409b81f0287a9004a6a..2369c1d6d735098651259c7fa070c1ffba76a7e8 100644 --- a/mysql-test/suite/galera/r/galera_sst_mysqldump.result +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump.result @@ -1,4 +1,6 @@ Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; @@ -352,102 +354,6 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; -Performing State Transfer on a server that has been killed and restarted -while a DDL was in progress on it -CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -START TRANSACTION; -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -COMMIT; -SET GLOBAL debug = 'd,sync.alter_opened_table'; -ALTER TABLE t1 ADD COLUMN f2 INTEGER; -SET wsrep_sync_wait = 0; -Killing server ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -COMMIT; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -Performing --wsrep-recover ... -Starting server ... -Using --wsrep-start-position when starting mysqld ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -COMMIT; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -ROLLBACK; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -COMMIT; -SET AUTOCOMMIT=ON; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -DROP TABLE t1; -COMMIT; -SET AUTOCOMMIT=ON; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); DROP USER sst; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); diff --git a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result index 227e1c15444ec5a16d41f5a32874ffb41364b39a..074481afc2d265391f4f5230b808b659f0be6fbf 100644 --- a/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result +++ b/mysql-test/suite/galera/r/galera_sst_mysqldump_with_key.result @@ -1,4 +1,6 @@ Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; @@ -105,5 +107,3 @@ CALL mtr.add_suppression("Can't open and lock privilege tables"); CALL mtr.add_suppression("Info table is not ready to be used"); CALL mtr.add_suppression("Native table .* has the wrong structure"); DROP USER sslsst; -SET GLOBAL general_log = ON; -SET GLOBAL slow_query_log = ON; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_rsync,debug.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..323a0a92a35f5bae00c8c0bf5f3c0fd2827119e5 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync,debug.rdiff @@ -0,0 +1,103 @@ +--- galera_sst_rsync.reject ++++ galera_sst_rsync.result +@@ -260,3 +260,100 @@ + DROP TABLE t1; + COMMIT; + SET AUTOCOMMIT=ON; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++SET wsrep_sync_wait = 0; ++Killing server ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++Performing --wsrep-recover ... ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++ROLLBACK; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++SET AUTOCOMMIT=ON; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET AUTOCOMMIT=ON; ++SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync.result b/mysql-test/suite/galera/r/galera_sst_rsync.result index df2d9190a4b56060e16164b87e238aea74342923..cec0f21ee22ae6c29957854a1aee7dc0d7da8cfc 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync.result @@ -260,100 +260,3 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; -Performing State Transfer on a server that has been killed and restarted -while a DDL was in progress on it -CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -START TRANSACTION; -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -COMMIT; -SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; -ALTER TABLE t1 ADD COLUMN f2 INTEGER; -SET wsrep_sync_wait = 0; -Killing server ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -COMMIT; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -Performing --wsrep-recover ... -Starting server ... -Using --wsrep-start-position when starting mysqld ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -COMMIT; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -ROLLBACK; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -COMMIT; -SET AUTOCOMMIT=ON; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -DROP TABLE t1; -COMMIT; -SET AUTOCOMMIT=ON; -SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2,debug.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..2692482f44801ecfff7ed70bc209f17fdb7c4e54 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2,debug.rdiff @@ -0,0 +1,103 @@ +--- galera_sst_xtrabackup-v2.reject ++++ galera_sst_xtrabackup-v2.result +@@ -260,3 +260,100 @@ + DROP TABLE t1; + COMMIT; + SET AUTOCOMMIT=ON; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++SET wsrep_sync_wait = 0; ++Killing server ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++Performing --wsrep-recover ... ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++COMMIT; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++ROLLBACK; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++SET AUTOCOMMIT=ON; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET AUTOCOMMIT=ON; ++SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2.result b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2.result index df2d9190a4b56060e16164b87e238aea74342923..cec0f21ee22ae6c29957854a1aee7dc0d7da8cfc 100644 --- a/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2.result +++ b/mysql-test/suite/galera/r/galera_sst_xtrabackup-v2.result @@ -260,100 +260,3 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; -Performing State Transfer on a server that has been killed and restarted -while a DDL was in progress on it -CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -INSERT INTO t1 VALUES ('node1_committed_before'); -START TRANSACTION; -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -INSERT INTO t1 VALUES ('node2_committed_before'); -COMMIT; -SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; -ALTER TABLE t1 ADD COLUMN f2 INTEGER; -SET wsrep_sync_wait = 0; -Killing server ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -INSERT INTO t1 (f1) VALUES ('node1_committed_during'); -COMMIT; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -Performing --wsrep-recover ... -Starting server ... -Using --wsrep-start-position when starting mysqld ... -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -INSERT INTO t1 (f1) VALUES ('node2_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); -COMMIT; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -INSERT INTO t1 (f1) VALUES ('node1_committed_after'); -COMMIT; -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); -ROLLBACK; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -COMMIT; -SET AUTOCOMMIT=ON; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 -SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; -COUNT(*) = 0 -1 -DROP TABLE t1; -COMMIT; -SET AUTOCOMMIT=ON; -SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_suspend_slave.result b/mysql-test/suite/galera/r/galera_suspend_slave.result index 357a0d4f78e7a6e7e3e8cb9d1e2b4364bc344214..ebddb4c449d890f900c4d123365779ae8eae373f 100644 --- a/mysql-test/suite/galera/r/galera_suspend_slave.result +++ b/mysql-test/suite/galera/r/galera_suspend_slave.result @@ -1,11 +1,11 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; Suspending node_2 ... +SET SESSION wsrep_sync_wait = 0; INSERT INTO t1 VALUES (1); Got one of the listed errors Resuming node_2 ... -SET SESSION wsrep_sync_wait = 1; INSERT INTO t1 VALUES (1); -SET SESSION wsrep_sync_wait = 1; +SET SESSION wsrep_sync_wait = 0; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_fk_insert.result b/mysql-test/suite/galera/r/galera_toi_ddl_fk_insert.result index 81781fbeae7b107d512a6686dfb8780b0284347b..1726bb6445f0691c8570bcf9fde5763e0b2c5838 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_fk_insert.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_fk_insert.result @@ -9,7 +9,7 @@ CREATE TABLE child ( id INT PRIMARY KEY AUTO_INCREMENT, parent_id INT ) ENGINE=InnoDB; -INSERT INTO parent VALUES (DEFAULT, 0); +INSERT INTO parent VALUES (1, 0); INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;; INSERT INTO parent (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;; INSERT INTO parent (f2) SELECT 2 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4;; diff --git a/mysql-test/suite/galera/r/galera_var_auto_inc_control_on.result b/mysql-test/suite/galera/r/galera_var_auto_inc_control_on.result index c1bb065975bbde9f8e10d49a1d4f04940954920e..b9b00cfe1ac00c32ddeab7038c452abea99b1114 100644 --- a/mysql-test/suite/galera/r/galera_var_auto_inc_control_on.result +++ b/mysql-test/suite/galera/r/galera_var_auto_inc_control_on.result @@ -2,16 +2,14 @@ CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size') 1 -SELECT @@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; -@@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1 +auto_increment_offset_differ 1 INSERT INTO t1 VALUES (DEFAULT, 'node1');; INSERT INTO t1 VALUES (DEFAULT, 'node2');; SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size') 1 -SELECT @@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; -@@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1 +auto_increment_offset_differ 1 INSERT INTO t1 VALUES (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2');; INSERT INTO t1 VALUES (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1');; diff --git a/mysql-test/suite/galera/r/galera_var_cluster_address.result b/mysql-test/suite/galera/r/galera_var_cluster_address.result index 7c56e22eca2fafac5e7a639c821c81a943e8c421..8245cdf609363a88ebac04ec3a0cdf2a0852da4c 100644 --- a/mysql-test/suite/galera/r/galera_var_cluster_address.result +++ b/mysql-test/suite/galera/r/galera_var_cluster_address.result @@ -1,7 +1,8 @@ SET GLOBAL wsrep_cluster_address = 'foo://'; SET SESSION wsrep_sync_wait=0; SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; -ERROR 08S01: WSREP has not yet prepared node for application use +COUNT(*) > 0 +1 SHOW STATUS LIKE 'wsrep_ready'; Variable_name Value wsrep_ready OFF diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index f141b332b6cfbabc5541c51c026211edf8ac0e6a..5a108ddfcaa7c1c778b53dfb4e345bf7de516f16 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -33,11 +33,12 @@ SELECT 1; 1 1 USE information_schema; -ERROR 08S01: WSREP has not yet prepared node for application use SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; -ERROR 08S01: WSREP has not yet prepared node for application use +VARIABLE_NAME VARIABLE_VALUE +WSREP_DIRTY_READS OFF SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; -ERROR 08S01: WSREP has not yet prepared node for application use +COUNT(*) >= 10 +1 USE test; SELECT * FROM t1; i diff --git a/mysql-test/suite/galera/r/galera_var_node_address.result b/mysql-test/suite/galera/r/galera_var_node_address.result index cf36e964f9397983dfb044a437be0d68269a2d2f..a9c900d8bc8c78614dd7e6dee601eaffef2453d3 100644 --- a/mysql-test/suite/galera/r/galera_var_node_address.result +++ b/mysql-test/suite/galera/r/galera_var_node_address.result @@ -1,5 +1,6 @@ call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); +call mtr.add_suppression("WSREP: Sending JOIN failed: -[0-9]+ (Transport endpoint is not connected). Will retry in new primary component."); SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 diff --git a/mysql-test/suite/galera/r/galera_var_reject_queries.result b/mysql-test/suite/galera/r/galera_var_reject_queries.result new file mode 100644 index 0000000000000000000000000000000000000000..5958e6ae981e21d36f4ac0804b6259c2c9694f5c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_var_reject_queries.result @@ -0,0 +1,21 @@ +CREATE TABLE t1 (f1 INTEGER); +SET SESSION wsrep_reject_queries = ALL; +ERROR HY000: Variable 'wsrep_reject_queries' is a GLOBAL variable and should be set with SET GLOBAL +SET GLOBAL wsrep_reject_queries = ALL; +SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +SET GLOBAL wsrep_reject_queries = ALL_KILL; +ERROR HY000: Lost connection to MySQL server during query +SELECT * FROM t1; +Got one of the listed errors +SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 2 +1 +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_reject_queries = NONE; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result index f4d17ad9a419e8e28d2a7a2e5953abde1de7a670..22a3105a588b958e941da18314fa7f000be176a2 100644 --- a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result +++ b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result @@ -1,32 +1,54 @@ -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; -CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; SET SESSION wsrep_retry_autocommit = 0; -INSERT INTO t1 (f1) VALUES (1),(2);; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +INSERT INTO t1 (f1) VALUES (2); +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; TRUNCATE TABLE t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; SET SESSION wsrep_retry_autocommit = 1; -INSERT INTO t1 (f1) VALUES (3),(4);; -TRUNCATE TABLE t1; -SELECT * FROM test.t1; -f1 f2 -3 0 -4 0 -CREATE PROCEDURE repeated_truncate () -BEGIN -DECLARE i INT; -DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; -SET i = 0; -WHILE i <= 1000 DO +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +INSERT INTO t1 (f1) VALUES (2); +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; TRUNCATE TABLE t1; -SET i = i + 1; -END WHILE; -END| -CALL repeated_truncate(); +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; SET SESSION wsrep_retry_autocommit = 1; -INSERT INTO t1 (f1) VALUES (5),(6); +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 2'; +INSERT INTO t1 VALUES (2);; +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; +TRUNCATE TABLE t1; +SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_rep'; +TRUNCATE TABLE t1; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SET SESSION wsrep_retry_autocommit = 1024; -INSERT INTO t1 (f1) VALUES (7),(8);; -include/diff_servers.inc [servers=1 2] +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 64; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 64'; +INSERT INTO t1 VALUES (2); +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; DROP TABLE t1; -DROP PROCEDURE repeated_truncate; diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result index 2340d25d160302cbab10666076854b01b258ca2b..70f3b8ee25707ecf50a5fddead29653f02866628 100644 --- a/mysql-test/suite/galera/r/galera_var_slave_threads.result +++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result @@ -1,6 +1,6 @@ -CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; +CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); SET GLOBAL wsrep_slave_threads = 0; Warnings: Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' @@ -22,9 +22,6 @@ INSERT INTO t1 VALUES (1); SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 -SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; -COUNT(*) = @@wsrep_slave_threads + 1 -1 SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; COUNT(*) = 1 1 @@ -96,9 +93,6 @@ INSERT INTO t2 VALUES (DEFAULT); SELECT COUNT(*) = 64 FROM t2; COUNT(*) = 64 1 -SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; -COUNT(*) = @@wsrep_slave_threads + 1 -1 SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; COUNT(*) = 1 1 @@ -111,5 +105,13 @@ DROP TABLE t2; CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB; SET GLOBAL wsrep_slave_threads = 4; SET GLOBAL wsrep_slave_threads = 1; +INSERT INTO t1 VALUES (DEFAULT); +INSERT INTO t1 VALUES (DEFAULT); +INSERT INTO t1 VALUES (DEFAULT); DROP TABLE t1; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +NAME +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; +COUNT(*) = 1 +1 # End of tests diff --git a/mysql-test/suite/galera/r/galera_wsrep_desync_wsrep_on.result b/mysql-test/suite/galera/r/galera_wsrep_desync_wsrep_on.result index 06fc27ae7ed8e7aceac1590a7209b83ba3493ded..5bde4874809603f5b6f0c70eea69766c1954b461 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_desync_wsrep_on.result +++ b/mysql-test/suite/galera/r/galera_wsrep_desync_wsrep_on.result @@ -2,6 +2,9 @@ CREATE TABLE ten (f1 INTEGER); INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +SELECT COUNT(*) = 100000 FROM t1; +COUNT(*) = 100000 +1 SET GLOBAL wsrep_desync = TRUE; SET SESSION wsrep_on = FALSE; ALTER TABLE t1 ADD PRIMARY KEY (f1); diff --git a/mysql-test/suite/galera/r/have_wsrep_replicate_myisam.require b/mysql-test/suite/galera/r/have_wsrep_replicate_myisam.require new file mode 100644 index 0000000000000000000000000000000000000000..c55610fd049fb102be25f8b965acff0934f5d90e --- /dev/null +++ b/mysql-test/suite/galera/r/have_wsrep_replicate_myisam.require @@ -0,0 +1,2 @@ +Variable_name Value +wsrep_replicate_myisam ON diff --git a/mysql-test/suite/galera/r/lp1376747-2.result b/mysql-test/suite/galera/r/lp1376747-2.result index 3b8aee61ed2a21002137adcf522758071e47110c..0c91e10acd7ed7ae176bc0702620d9187c4bca2c 100644 --- a/mysql-test/suite/galera/r/lp1376747-2.result +++ b/mysql-test/suite/galera/r/lp1376747-2.result @@ -1,5 +1,8 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +NAME +test/t1 FLUSH TABLES t1 FOR EXPORT; ALTER TABLE t1 ADD COLUMN f2 INTEGER; INSERT INTO t1 VALUES (2,3); diff --git a/mysql-test/suite/galera/r/lp1376747.result b/mysql-test/suite/galera/r/lp1376747.result index 4617d5952bbd7cde11b1ade84ee68b8e39c4714b..ec6c4a6e6f49eede5367e373522e3502da0bbcf4 100644 --- a/mysql-test/suite/galera/r/lp1376747.result +++ b/mysql-test/suite/galera/r/lp1376747.result @@ -1,5 +1,8 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +NAME +test/t1 FLUSH TABLES t1 WITH READ LOCK; ALTER TABLE t1 ADD COLUMN f2 INTEGER; INSERT INTO t1 VALUES (2,3); diff --git a/mysql-test/suite/galera/r/mysql-wsrep#33.result b/mysql-test/suite/galera/r/mysql-wsrep#33.result index fc647a2000daf7f3b9451f73abf961ca520b3ac0..3e8cfdb42d3430588bb86b627cdb8ea7488737a7 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#33.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#33.result @@ -1,4 +1,6 @@ Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; @@ -100,5 +102,4 @@ CALL mtr.add_suppression("Can't open and lock time zone table"); CALL mtr.add_suppression("Can't open and lock privilege tables"); CALL mtr.add_suppression("Info table is not ready to be used"); CALL mtr.add_suppression("Native table .* has the wrong structure"); -SET GLOBAL general_log = ON; -SET GLOBAL slow_query_log = ON; +Restarting server ... diff --git a/mysql-test/suite/galera/r/mysql-wsrep#90.result b/mysql-test/suite/galera/r/mysql-wsrep#90.result index da57b9d00684ee936cebd9525524619e9a2ca98b..7ecaff7707e7bffc29176f0a889a891eebb59256 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#90.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#90.result @@ -12,6 +12,7 @@ SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; COUNT(*) = 2 1 DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; SET GLOBAL wsrep_OSU_method = "TOI"; SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; @@ -29,3 +30,4 @@ COUNT(*) = 2 INSERT INTO t1 VALUES (3,4); DROP TABLE t1; SET GLOBAL WSREP_OSU_METHOD = TOI; +SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/galera/r/pxc-421.result b/mysql-test/suite/galera/r/pxc-421.result index f5c0fabcd6e0aceaef92f87622936e4258bef4bb..1822201f3381a7f2f1ad9c8161672fc24bf2f4fe 100644 --- a/mysql-test/suite/galera/r/pxc-421.result +++ b/mysql-test/suite/galera/r/pxc-421.result @@ -6,7 +6,6 @@ set GLOBAL wsrep_slave_threads=16; SET GLOBAL wsrep_provider='none'; INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); -set SESSION wsrep_sync_wait=0; INSERT INTO t1 VALUES (4); set GLOBAL wsrep_slave_threads=5; SELECT COUNT(*) = 5 FROM t1; @@ -26,7 +25,6 @@ SET GLOBAL wsrep_slave_threads = 1; SELECT COUNT(*) FROM t1; COUNT(*) 16 -SET GLOBAL auto_increment_offset = 2; SELECT COUNT(*) FROM t1; COUNT(*) 15 @@ -35,4 +33,3 @@ Variable_name Value wsrep_slave_threads 12 SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; -SET GLOBAL auto_increment_offset = 1; diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 361743f1243b4ee6f606ac167031515ad12501c7..5cdb751a43479abb457c5b20407f816c3e327bd2 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -1,4 +1,4 @@ -package My::Suite::GALERA; +package My::Suite::Galera; use File::Basename; use My::Find; @@ -25,6 +25,10 @@ return "No scritps" unless $cpath; my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; return "No my_print_defaults" unless $epath; +my ($bpath) = grep { -f "$_/mariabackup"; } "$::bindir/extra/mariabackup", $::path_client_bindir; + +sub which($) { return `sh -c "command -v $_[0]"` } + push @::global_suppressions, ( qr(WSREP: wsrep_sst_receive_address is set to '127.0.0.1), @@ -77,10 +81,30 @@ push @::global_suppressions, qr|WSREP: JOIN message from member .* in non-primary configuration. Ignored.|, ); - $ENV{PATH}="$epath:$ENV{PATH}"; $ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; $ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; +$ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $spath; -bless { }; +if (which(socat)) { + $ENV{MTR_GALERA_TFMT}='socat'; +} elsif (which(nc)) { + $ENV{MTR_GALERA_TFMT}='nc'; +} + +sub skip_combinations { + my %skip = (); + $skip{'include/have_xtrabackup.inc'} = 'Need innobackupex' + unless which(innobackupex); + $skip{'include/have_xtrabackup.inc'} = 'Need socat or nc' + unless $ENV{MTR_GALERA_TFMT}; + $skip{'include/have_mariabackup.inc'} = 'Need mariabackup' + unless which(mariabackup); + $skip{'include/have_mariabackup.inc'} = 'Need ss' + unless which(ss); + $skip{'include/have_mariabackup.inc'} = 'Need socat or nc' + unless $ENV{MTR_GALERA_TFMT}; + %skip; +} +bless { }; diff --git a/mysql-test/suite/galera/t/MW-284.test b/mysql-test/suite/galera/t/MW-284.test index 7add82f122796eb5a6f9d33f519df189e64c7e53..5e17baa1bdb2a7fef8e532a89d377ffc7590e7d7 100644 --- a/mysql-test/suite/galera/t/MW-284.test +++ b/mysql-test/suite/galera/t/MW-284.test @@ -24,7 +24,6 @@ SET global wsrep_sync_wait=0; --connection node_3 START SLAVE; ---sleep 1 --let $slave_param= Slave_IO_Running --let $slave_param_value= Connecting --source include/wait_for_slave_param.inc @@ -38,6 +37,7 @@ SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; --source include/wait_for_slave_to_start.inc --connection node_1 +--source include/galera_wait_ready.inc INSERT INTO t1 VALUES (1); --connection node_3 @@ -61,3 +61,10 @@ RESET SLAVE ALL; CALL mtr.add_suppression('failed registering on master'); CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); + +--connection node_1 +RESET MASTER; +CALL mtr.add_suppression('WSREP: Last Applied Action message in non-primary configuration from member'); + +--connection node_2 +CALL mtr.add_suppression('WSREP: Last Applied Action message in non-primary configuration from member'); \ No newline at end of file diff --git a/mysql-test/suite/galera/t/MW-286.test b/mysql-test/suite/galera/t/MW-286.test index 08deb317fbe5fbaffcfbfb2f340cea9a286ec1a5..1b2e322f078f8e7e38ec21b942d557d6d5e74f4d 100644 --- a/mysql-test/suite/galera/t/MW-286.test +++ b/mysql-test/suite/galera/t/MW-286.test @@ -25,7 +25,6 @@ SET wsrep_on = FALSE; --error ER_QUERY_INTERRUPTED ALTER TABLE t1 ADD PRIMARY KEY (f1); -SET SESSION wsrep_sync_wait = 0; SET wsrep_on = TRUE; SET GLOBAL wsrep_desync = FALSE; diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test index d9f9a787442507b4957f72471c25dad955677d49..bf045832113f661e353dfd714b6036ecd8d7d05b 100644 --- a/mysql-test/suite/galera/t/MW-329.test +++ b/mysql-test/suite/galera/t/MW-329.test @@ -83,3 +83,5 @@ DROP TABLE t1; # Due to MW-330, Multiple "conflict state 3 after post commit" warnings if table is dropped while SP is running CALL mtr.add_suppression("conflict state 3 after post commit"); + +set global innodb_status_output=Default; \ No newline at end of file diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test index 79d8951a822cd030c719a5fe8383ec30ac129038..9572489ebe985c9db89ee47e7fa3283e07039942 100644 --- a/mysql-test/suite/galera/t/MW-336.test +++ b/mysql-test/suite/galera/t/MW-336.test @@ -10,20 +10,20 @@ CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; --connection node_1 SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 1; +--let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc --connection node_2 INSERT INTO t1 VALUES (1); --connection node_1 ---sleep 0.5 SET GLOBAL wsrep_slave_threads = 10; ---sleep 0.5 -SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc SET GLOBAL wsrep_slave_threads = 20; ---sleep 0.5 -SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; - +--let $wait_condition = SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc SET GLOBAL wsrep_slave_threads = 1; @@ -40,6 +40,9 @@ INSERT INTO t1 VALUES (9); --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 12 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc + SET GLOBAL wsrep_slave_threads = 10; SET GLOBAL wsrep_slave_threads = 0; @@ -57,8 +60,8 @@ INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (20); --connection node_1 ---sleep 0.5 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-416.test b/mysql-test/suite/galera/t/MW-416.test new file mode 100644 index 0000000000000000000000000000000000000000..df4fa35abc781fa479b839214e0194e86229d1c1 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-416.test @@ -0,0 +1,134 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source include/wait_until_ready.inc + +CREATE USER 'userMW416'@'localhost'; +GRANT SELECT, INSERT, UPDATE ON test.* TO 'userMW416'@'localhost'; + +SHOW GLOBAL STATUS LIKE 'wsrep_replicated'; + +--connect userMW416, localhost, userMW416,, test, $NODE_MYPORT_1 +--connection userMW416 + +# DDL + +--error 1044 +ALTER DATABASE db CHARACTER SET = utf8; +--error 1044 +ALTER EVENT ev1 RENAME TO ev2; +--error 1370 +ALTER FUNCTION fun1 COMMENT 'foo'; +#--error 1044,1227 +#ALTER INSTANCE ROTATE INNODB MASTER KEY; +--error 1044,1227 +ALTER LOGFILE GROUP lfg ADD UNDOFILE 'file' ENGINE=InnoDB; +--error 1044,1227,1370 +ALTER PROCEDURE proc1 COMMENT 'foo'; +--error 1044,1227,1370 +ALTER SERVER srv OPTIONS (USER 'sally'); +--error 1044,1142,1227,1370 +ALTER TABLE tbl DROP COLUMN col; +--error 1044,1227,1370 +ALTER TABLESPACE tblspc DROP DATAFILE 'file' ENGINE=innodb; +--error 1044,1142,1227,1370 +ALTER VIEW vw AS SELECT 1; + +--error 1044,1227,1370 +CREATE DATABASE db; +--error 1044,1227,1370 +CREATE EVENT ev1 ON SCHEDULE AT CURRENT_TIMESTAMP DO SELECT 1; +--error 1044,1227,1370 +CREATE FUNCTION fun1() RETURNS int RETURN(1); +--error 1044,1227,1370 +CREATE FUNCTION fun1 RETURNS STRING SONAME 'funlib.so'; +--error 1044,1227,1370 +CREATE PROCEDURE proc1() BEGIN END; +--error 1044,1142,1227,1370 +CREATE INDEX idx ON tbl(id); +--error 1044,1142,1227,1370 +CREATE LOGFILE GROUP lfg ADD UNDOFILE 'undofile' ENGINE innodb; +--error 1044,1142,1227,1370 +CREATE SERVER srv FOREIGN DATA WRAPPER 'fdw' OPTIONS (USER 'user'); +--error 1044,1142,1227,1370 +CREATE TABLE t (i int); +--error 1044,1142,1227,1370 +CREATE TABLESPACE tblspc ADD DATAFILE 'file' ENGINE=innodb; +--error 1044,1142,1227,1370 +CREATE TRIGGER trg BEFORE UPDATE ON t FOR EACH ROW BEGIN END; +--error 1044,1142,1227,1370 +CREATE VIEW vw AS SELECT 1; + + + +--error 1044,1142,1227,1370 +DROP DATABASE db; +--error 1044,1142,1227,1370 +DROP EVENT ev; +--error 1044,1142,1227,1370 +DROP FUNCTION fun1; +--error 1044,1142,1227,1370 +DROP INDEX idx ON t0; +--error 1044,1142,1227,1370,1064 +DROP LOGFILE GROUP lfg; +--error 1044,1142,1227,1370 +DROP PROCEDURE proc1; +--error 1044,1142,1227,1370 +DROP SERVEr srv; +--error 1044,1142,1227,1370 +DROP TABLE t0; +--error 1044,1142,1227,1370,1064 +DROP TABLESPACE tblspc; +--error 1044,1142,1227,1360,1370 +DROP TRIGGER trg; +--error 1044,1142,1227,1370 +DROP VIEW vw; + +--error 1044,1142,1227,1370 +RENAME TABLE t0 TO t1; + +--error 1044,1142,1227,1370 +TRUNCATE TABLE t0; + +# DCL + +# account management +--error 1044,1142,1227,1370,1064 +ALTER USER myuser PASSWORD EXPIRE; +--error 1044,1142,1227,1370 +CREATE USER myuser IDENTIFIED BY 'pass'; +--error 1044,1142,1227,1370 +DROP USER myuser; +--error 1044,1045,1142,1227,1370 +GRANT ALL ON *.* TO 'myuser'; +--error 1044,1142,1227,1370 +RENAME USER myuser TO mariauser; +--error 1044,1142,1227,1370 +REVOKE SELECT ON test FROM myuser; +--error 1044,1142,1227,1370,1698 +REVOKE ALL, GRANT OPTION FROM myuser; +--error 1044,1142,1227,1370,1698 +REVOKE PROXY ON myuser FROM myuser; + +# table maintenance +--error 1044,1142,1227,1370 +ANALYZE TABLE db.tbl; +--error 1044,1142,1227,1370 +CHECK TABLE db.tbl; +--error 1044,1142,1227,1370 +CHECKSUM TABLE db.tbl; +--error 1044,1142,1227,1370 +OPTIMIZE TABLE db.tbl; +--error 1044,1142,1227,1370 +REPAIR TABLE db.tbl; + +# plugin and user defined functions +--error 1044,1142,1227,1370 +INSTALL PLUGIN plg SONAME 'plg.so'; +--error 1044,1142,1227,1370 +UNINSTALL PLUGIN plg; + +--connection node_1 +DROP USER 'userMW416'@'localhost'; +SHOW DATABASES; +SHOW GLOBAL STATUS LIKE 'wsrep_replicated'; diff --git a/mysql-test/suite/galera/t/MW-44.test b/mysql-test/suite/galera/t/MW-44.test index 55a3fd57f80232740a7724b72f7e3d39c4edacaa..09f444fdff43c42b5ad065e3c876d766e6080445 100644 --- a/mysql-test/suite/galera/t/MW-44.test +++ b/mysql-test/suite/galera/t/MW-44.test @@ -6,12 +6,20 @@ --source include/have_innodb.inc --connection node_1 +SET GLOBAL general_log='OFF'; TRUNCATE TABLE mysql.general_log; +SELECT COUNT(*) from mysql.general_log; +SELECT * FROM mysql.general_log; --connection node_2 +SET GLOBAL general_log='OFF'; TRUNCATE TABLE mysql.general_log; +SELECT COUNT(*) from mysql.general_log; +SELECT * FROM mysql.general_log; --connection node_1 +SET GLOBAL general_log='ON'; +SELECT COUNT(*) from mysql.general_log; SET SESSION wsrep_osu_method=TOI; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; SET SESSION wsrep_osu_method=RSU; @@ -21,5 +29,7 @@ SET SESSION wsrep_osu_method=TOI; SELECT COUNT(*) = 2 FROM mysql.general_log WHERE argument LIKE 'CREATE%' OR argument LIKE 'ALTER%'; --connection node_2 +SET GLOBAL general_log='ON'; SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument NOT LIKE 'SELECT%'; DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera#500.test b/mysql-test/suite/galera/t/galera#500.test new file mode 100644 index 0000000000000000000000000000000000000000..3c8490b690770c783f521e46357fcb69d890ae1f --- /dev/null +++ b/mysql-test/suite/galera/t/galera#500.test @@ -0,0 +1,38 @@ +# +# The purpose of this test is to verify that if an exception is +# thrown from gcomm background thread, the provider terminates properly +# and wsrep_ready becomes 0. +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc +--source include/galera_have_debug_sync.inc + +# Force node_2 gcomm background thread to terminate via exception. +--connection node_2 +--let $wsrep_cluster_address = `SELECT @@wsrep_cluster_address` +# Setting gmcast.isolate=2 will force gcomm background thread to +# throw exception. +SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options="gmcast.isolate=2"; + +# Wait until wsrep_ready becomes 0. +--let $wait_condition = SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME ='wsrep_ready' +--source include/wait_condition.inc + +# Wait until node_1 ends up in non-prim and rebootstrap the cluster. +--connection node_1 +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME ='wsrep_cluster_size' +--source include/wait_condition.inc +SHOW STATUS LIKE 'wsrep_cluster_status'; +SET SESSION wsrep_sync_wait = default; +SET GLOBAL wsrep_provider_options="pc.bootstrap=1"; + +# Restart node_2 +--connection node_2 +SET SESSION wsrep_on=0; +--source include/restart_mysqld.inc + +--connection node_2 +CALL mtr.add_suppression("WSREP: exception from gcomm, backend must be restarted: Gcomm backend termination was requested by setting gmcast.isolate=2."); diff --git a/mysql-test/suite/galera/t/galera_as_master.test b/mysql-test/suite/galera/t/galera_as_master.test index 93f9224b2589a106278c41f82973d8687b2a0359..49f3c99325681ed7b405de8e2faeef71f43b74af 100644 --- a/mysql-test/suite/galera/t/galera_as_master.test +++ b/mysql-test/suite/galera/t/galera_as_master.test @@ -35,14 +35,14 @@ SELECT * FROM t3; SELECT * FROM t4; --connection node_3 -SHOW TABLES; - --let $wait_condition = SELECT COUNT(*) = 2 FROM t1; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 3 FROM t4; --source include/wait_condition.inc +SHOW TABLES; + SELECT * FROM t1; SELECT * FROM t4; @@ -63,3 +63,5 @@ RESET SLAVE ALL; CALL mtr.add_suppression('You need to use --log-bin to make --binlog-format work'); +--connection node_1 +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test index 30ce9bc4ceb45e6087fdcc55984021bc202315da..cd7621bfa6ec48640b6334d204c38ee1ca5d9ea0 100644 --- a/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test +++ b/mysql-test/suite/galera/t/galera_autoinc_sst_xtrabackup.test @@ -6,6 +6,7 @@ --source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_xtrabackup.inc --connection node_1 --let $connection_id = `SELECT CONNECTION_ID()` diff --git a/mysql-test/suite/galera/t/galera_bf_abort_for_update.test b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test index 24c29778e5d28ea3d1fd9e7ba55be22fc9ed27f9..13e48f8f3cecc2726f85b19da8724579c0254dab 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_for_update.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test @@ -5,25 +5,52 @@ # Test a local transaction being aborted by a slave one while it is running a SELECT FOR UPDATE # -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INT) ENGINE=InnoDB; ---connection node_2 ---let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1, 10); + +# Test updating the PK --connection node_1 -INSERT INTO t1 VALUES (1); +--let $wsrep_local_bf_aborts_before = `SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'` +BEGIN; +SELECT * FROM t1 FOR UPDATE; --connection node_2 +UPDATE t1 SET f1 = 2; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--let $wait_condition = SELECT COUNT(*) FROM t1 WHERE f1 = 2 +--source include/wait_condition.inc + +--connection node_1 --error ER_LOCK_DEADLOCK +COMMIT; + +--disable_query_log +--eval SELECT variable_value - $wsrep_local_bf_aborts_before AS wsrep_local_bf_aborts_diff FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts' +--enable_query_log + +# Test updating non-indexed column + +--connection node_1 +--let $wsrep_local_bf_aborts_before = `SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'` +BEGIN; SELECT * FROM t1 FOR UPDATE; ---let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +--connection node_2 +UPDATE t1 SET f2 = 20; + +--connection node_1a +--let $wait_condition = SELECT COUNT(*) FROM t1 WHERE f2 = 20 +--source include/wait_condition.inc + +--connection node_1 +--error ER_LOCK_DEADLOCK +COMMIT; --disable_query_log ---eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--eval SELECT variable_value - $wsrep_local_bf_aborts_before AS wsrep_local_bf_aborts_diff FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts' --enable_query_log DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_concurrent_ctas.test b/mysql-test/suite/galera/t/galera_concurrent_ctas.test index f0dcf8e49008544d56e4179075917bedfabae52c..6c4e8be68a79fbdcf9651923e32c00ee593e3366 100644 --- a/mysql-test/suite/galera/t/galera_concurrent_ctas.test +++ b/mysql-test/suite/galera/t/galera_concurrent_ctas.test @@ -43,9 +43,9 @@ let $run=10; while($run) { --error 0,1 - exec $MYSQL --user=root --host=127.0.0.1 --port=$NODE_MYPORT_1 test - < $MYSQLTEST_VARDIR/tmp/galera_concurrent.sql & - $MYSQL --user=root --host=127.0.0.1 --port=$NODE_MYPORT_2 test + exec $MYSQL --user=root --host=127.0.0.1 --port=$NODE_MYPORT_1 test \ + < $MYSQLTEST_VARDIR/tmp/galera_concurrent.sql & \ + $MYSQL --user=root --host=127.0.0.1 --port=$NODE_MYPORT_2 test \ < $MYSQLTEST_VARDIR/tmp/galera_concurrent.sql; dec $run; } diff --git a/mysql-test/suite/galera/t/galera_defaults.test b/mysql-test/suite/galera/t/galera_defaults.test index 32fc24097d26b34f997033c66e0829dda1024f55..facc5180f2f7509d966117327145b98e76ce0a0c 100644 --- a/mysql-test/suite/galera/t/galera_defaults.test +++ b/mysql-test/suite/galera/t/galera_defaults.test @@ -56,6 +56,7 @@ ORDER BY VARIABLE_NAME; $wsrep_provider_options =~ s/evs\.evict = .*?;/;/sgio; $wsrep_provider_options =~ s/signal = .*?;\s*//sgio; $wsrep_provider_options =~ s/dbug = .*?;\s*//sgio; + $wsrep_provider_options =~ s/repl.proto_max = .*?;\s*/;/sgio; print $wsrep_provider_options."\n"; EOF diff --git a/mysql-test/suite/galera/t/galera_encrypt_tmp_files.cnf b/mysql-test/suite/galera/t/galera_encrypt_tmp_files.cnf new file mode 100644 index 0000000000000000000000000000000000000000..0f7f80b7d0bf11d84e7b38bb8279d4dc0bfe673c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_encrypt_tmp_files.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf +[mysqld] + +encrypt-tmp-files = 1 +plugin-load-add= @ENV.FILE_KEY_MANAGEMENT_SO +file-key-management +loose-file-key-management-filename= @ENV.MYSQL_TEST_DIR/std_data/keys.txt +log-bin diff --git a/mysql-test/suite/galera/t/galera_encrypt_tmp_files.test b/mysql-test/suite/galera/t/galera_encrypt_tmp_files.test new file mode 100644 index 0000000000000000000000000000000000000000..c42c3dbd98af8ffbb51d9004fda9beb0b28f514f --- /dev/null +++ b/mysql-test/suite/galera/t/galera_encrypt_tmp_files.test @@ -0,0 +1,57 @@ +# This file tests that mariadb cluster should not crash when encrypt_tmp_file +# is enabled + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +--connection node_1 + +CREATE TABLE `t1` ( + `col1` int(11) NOT NULL, + `col2` varchar(64) NOT NULL DEFAULT '', + `col3` varchar(32) NOT NULL DEFAULT '0', + `col4` varchar(64) NOT NULL DEFAULT '', + `col5` tinyint(4) NOT NULL DEFAULT '0', + `col6` int(11) NOT NULL DEFAULT '0', + `col7` varchar(64) NOT NULL DEFAULT '', + `col8` tinyint(4) NOT NULL DEFAULT '0', + `col9` tinyint(4) NOT NULL DEFAULT '0', + `col10` text NOT NULL, + `col11` varchar(255) NOT NULL DEFAULT '', + `col12` tinyint(4) NOT NULL DEFAULT '1' +) ; + +#Although we just need $counter >= 907 for IO_CACHE to use +#encrypted temp file. Just on safe side I am using $counter +# = 1100 +--disable_query_log +--let $counter=1100 +--let $query= (1,'test','test','test',0,0,'-1',0,0,'','',-1) +while($counter) +{ + --let $query= $query ,(1,'test','test','test',0,0,'-1',0,0,'','',-1) + --dec $counter +} +--let $query= INSERT INTO t1 values $query ; +--eval $query +--enable_query_log +#INSERT INTO `t1` VALUE + +create table t2 (test int); +insert into t2 values (1); + +drop table t1,t2; diff --git a/mysql-test/suite/galera/t/galera_flush_local.opt b/mysql-test/suite/galera/t/galera_flush_local.opt index 5a1fb6748d95584b4a9aedb0a24a1493dad83373..a084db15c5dd4dfc64f7d481472c27d2cbcb1e26 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.opt +++ b/mysql-test/suite/galera/t/galera_flush_local.opt @@ -1 +1,3 @@ ---query_cache_type=1 --query_cache_size=1000000 +--query_cache_type=1 +--query_cache_size=1000000 +--wsrep_replicate_myisam=ON diff --git a/mysql-test/suite/galera/t/galera_flush_local.test b/mysql-test/suite/galera/t/galera_flush_local.test index 768f4ea4f1b9a4f2389dc10cf57ff4af4d584eb6..24acd9ec4ffa4054329bd0763ba2dd3fd8c76d48 100644 --- a/mysql-test/suite/galera/t/galera_flush_local.test +++ b/mysql-test/suite/galera/t/galera_flush_local.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc --source include/have_query_cache.inc +--source include/have_wsrep_replicate_myisam.inc --disable_warnings DROP TABLE IF EXISTS t1, t2, x1, x2; diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test index 3bfcdc9f117ac15a7e30233b36b646f10e1bf6b5..08165f30f7d3d7812c13ec51c709340ccd0bc51d 100644 --- a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test +++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/big_test.inc +--source include/have_log_bin.inc SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; @@ -93,6 +94,8 @@ END| DELIMITER ;| +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + --connect node_1_insert_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connect node_1_insert_multi, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connect node_1_insert_transaction, 127.0.0.1, root, , test, $NODE_MYPORT_1 @@ -124,6 +127,13 @@ DELIMITER ;| --connection node_2 SET SESSION wsrep_sync_wait = 0; + +# Make sure that node_2 is not killed while TOIs are applied. +# Otherwhise we risk that grastate file is marked unsafe, and +# as a consequence the node cannot rejoin with IST. +--let $wait_condition = SELECT VARIABLE_VALUE > $wsrep_last_committed_before FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed' +--source include/wait_condition.inc + --source include/kill_galera.inc --sleep 10 @@ -172,9 +182,8 @@ SET SESSION wsrep_sync_wait = 0; --source include/start_mysqld.inc --connection node_1 ---source include/wait_until_connected_again.inc ---source include/galera_wait_ready.inc --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc --let $diff_servers = 1 2 --source include/diff_servers.inc diff --git a/mysql-test/suite/galera/t/galera_gcs_fragment.test b/mysql-test/suite/galera/t/galera_gcs_fragment.test index ae1e0d8bab0726e5944692fa4521854eb7597526..80d3a5cb6598474c20d27e9f30dd270684f0712c 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fragment.test +++ b/mysql-test/suite/galera/t/galera_gcs_fragment.test @@ -1,6 +1,12 @@ # Test fragmentation over configuration changes --source include/galera_cluster.inc --source include/have_innodb.inc +--source suite/galera/include/galera_have_debug_sync.inc + +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc # Prepare table CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 TEXT); @@ -64,3 +70,5 @@ SELECT * FROM t1; --connection node_1 DROP TABLE t1; + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_gra_log.test b/mysql-test/suite/galera/t/galera_gra_log.test index 5329dc245461db2c239cbfa71f84426684ef4013..8b5aaaae5bd8f39c35e4b07efc34424c3c03ee09 100644 --- a/mysql-test/suite/galera/t/galera_gra_log.test +++ b/mysql-test/suite/galera/t/galera_gra_log.test @@ -17,21 +17,13 @@ CREATE TABLE t1 (f1 INTEGER); CREATE TABLE t1 (f1 INTEGER); --connection node_2 +SET SESSION wsrep_on=ON; SELECT COUNT(*) = 0 FROM t1; -# Compose a valid binlog from a header file and the GRA file - ---let $gra_binlog_file = $MYSQLTEST_VARDIR/tmp/gra.log ---exec rm -rf $gra_binlog_file - ---exec cp std_data/binlog-header.log $gra_binlog_file ---exec cat $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log >> $gra_binlog_file +# Make sure the GRA file produced is readable and contains the failure -# Make sure the binlog thus produced is readable and contains the failure ---replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=/ /#[0-9]+ +[0-9]+:[0-9]+:[0-9]+// /pseudo_thread_id=[0-9]+/pseudo_thread_id=/ /thread_id=[0-9]+/thread_id=/ ---exec $MYSQL_BINLOG $gra_binlog_file - -SET SESSION wsrep_on=ON; +--replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=/ /pseudo_thread_id=[0-9]+/pseudo_thread_id=/ +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query"); diff --git a/mysql-test/suite/galera/t/galera_gtid_slave.test b/mysql-test/suite/galera/t/galera_gtid_slave.test index 8ef87452a5bc023185e2480c140106e14a215821..19bfd8e17dbb516990c0f07c640ae6cc50ec7bf8 100644 --- a/mysql-test/suite/galera/t/galera_gtid_slave.test +++ b/mysql-test/suite/galera/t/galera_gtid_slave.test @@ -38,7 +38,13 @@ SELECT @@global.gtid_binlog_state; --let $wait_condition = SELECT COUNT(*) = 1 FROM t1; --source include/wait_condition.inc ---sleep 1 + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 2 FROM t2; +--source include/wait_condition.inc + INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); SELECT @@global.gtid_binlog_state; @@ -52,14 +58,6 @@ SELECT @@global.gtid_binlog_state; --connection node_1 DROP TABLE t1,t2; -reset master; -# -# Unfortunately without the sleep below the following statement fails with "query returned no rows", which -# is difficult to understand given that it is an aggregate query. A "query execution was interrupted" -# warning is also reported by MTR, which is also weird. -# - ---sleep 1 --connection node_2 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; @@ -76,3 +74,6 @@ reset master; --connection node_3 reset master; + +--connection node_1 +reset master; diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.test b/mysql-test/suite/galera/t/galera_ist_mysqldump.test index a9ff8c41f0641fa3b67331a8df1a707063293d35..f60d5549edaf6cd1613e6d69f0d45be969bd898e 100644 --- a/mysql-test/suite/galera/t/galera_ist_mysqldump.test +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.test @@ -4,6 +4,10 @@ --source suite/galera/include/galera_sst_set_mysqldump.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # mysql-wsrep#33 - nnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx_sys_update_wsrep_checkpoint with mysqldump IST # --source suite/galera/include/galera_st_disconnect_slave.inc @@ -14,4 +18,5 @@ --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc --source suite/galera/include/galera_sst_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test index 8b399e77794c058fa2e4a932bfd6cac0a2d6d7e2..c44b064234252cd5db5ebe6566a16e5b7f94896b 100644 --- a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test +++ b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test @@ -1,6 +1,7 @@ --source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_xtrabackup.inc --source suite/galera/include/galera_st_disconnect_slave.inc --source suite/galera/include/galera_st_shutdown_slave.inc diff --git a/mysql-test/suite/galera/t/galera_kill_nochanges.test b/mysql-test/suite/galera/t/galera_kill_nochanges.test index 1903df449e43135b660f5abee3a6359be61510d0..4106378885fa60fbe5980130b0e2d4c4c7202a56 100644 --- a/mysql-test/suite/galera/t/galera_kill_nochanges.test +++ b/mysql-test/suite/galera/t/galera_kill_nochanges.test @@ -11,6 +11,14 @@ INSERT INTO t1 VALUES (1); --connection node_2 --source include/kill_galera.inc + +--connection node_1 +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' +--source include/wait_condition.inc +SET SESSION wsrep_sync_wait = DEFAULT; + +--connection node_2 --source include/start_mysqld.inc --let $galera_connection_name = node_2a diff --git a/mysql-test/suite/galera/t/galera_lock_table.test b/mysql-test/suite/galera/t/galera_lock_table.test index bd581842f6fa076b7988e7da9cc878d0928cfcc6..2745bfe5faf87a1cea19aca72b55f3869c077456 100644 --- a/mysql-test/suite/galera/t/galera_lock_table.test +++ b/mysql-test/suite/galera/t/galera_lock_table.test @@ -12,6 +12,13 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; --connection node_2 + +# Wait until above DDL's are replicated +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; + LOCK TABLE t1 READ; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_many_tables_pk.test b/mysql-test/suite/galera/t/galera_many_tables_pk.test index 551307b123f5844814c2665fd927a57584e45af1..73c5fc1622c739e02ba6da9d00864a84e5cca52a 100644 --- a/mysql-test/suite/galera/t/galera_many_tables_pk.test +++ b/mysql-test/suite/galera/t/galera_many_tables_pk.test @@ -16,7 +16,7 @@ if (!`SELECT @@open_files_limit >= 1024`){ while ($count) { --disable_query_log - --let $ddl_var = `SELECT CONCAT("CREATE TABLE t", $count, " (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB")` + --let $ddl_var = `SELECT CONCAT("CREATE TABLE t", $count, " (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB")` --eval $ddl_var --enable_query_log --dec $count @@ -37,7 +37,7 @@ START TRANSACTION; while ($count) { --disable_query_log - --let $ddl_var = `SELECT CONCAT("INSERT INTO t", $count, " VALUES (DEFAULT)")` + --let $ddl_var = `SELECT CONCAT("INSERT INTO t", $count, " VALUES (1)")` --eval $ddl_var --enable_query_log --dec $count diff --git a/mysql-test/suite/galera/t/galera_mdev_15611.cnf b/mysql-test/suite/galera/t/galera_mdev_15611.cnf new file mode 100644 index 0000000000000000000000000000000000000000..b6f601c56b1fe0205202573c132f3912fd318e51 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_mdev_15611.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes.cnf +[mysqld.1] + +[mysqld.2] +wsrep_slave_threads=6 diff --git a/mysql-test/suite/galera/t/galera_mdev_15611.test b/mysql-test/suite/galera/t/galera_mdev_15611.test new file mode 100644 index 0000000000000000000000000000000000000000..d32d7e7526282873a7a56cdb15db77d1927df8c6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_mdev_15611.test @@ -0,0 +1,30 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 ( + id int primary key +); + +CREATE TABLE t2 ( + id int primary key , + f_id int DEFAULT NULL, FOREIGN KEY(f_id) REFERENCES t1 (id) +); + +insert into t1 select 1; + +--disable_query_log +--let $count=200 +--echo #Running 200 insert in t2 table +while($count) +{ + #Repeatedly execute the following SQL until you generate thousands of data + --eval insert into t2 values ($count, 1); + --dec $count +} +--enable_query_log + +select count(*) from t2; +delete from t2; +delete from t1; +drop table t2,t1; diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test index 41cd0c8e6fae783fb84855a80659d05ae9a48b01..2cd840123cff43eccebeb21d22c1016f9ca65572 100644 --- a/mysql-test/suite/galera/t/galera_parallel_simple.test +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -13,6 +13,13 @@ CREATE TABLE t2 (id INT) ENGINE=InnoDB; --connection node_2 SET GLOBAL wsrep_slave_threads = 2; + +# Wait until above DDL's are replicated +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; + LOCK TABLE t1 WRITE; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test index 84fd3a9185707bfeec526dceaf192466c530c4a2..f24ca5cd25b7b115f4726f1e8c26cc84c28bee5c 100644 --- a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test +++ b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test @@ -20,6 +20,9 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; --source include/kill_galera.inc --connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); DROP TABLE t1; @@ -37,10 +40,8 @@ SET GLOBAL wsrep_cluster_address = ''; --connection node_2 --source include/start_mysqld.inc ---source include/wait_until_connected_again.inc # Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc --source include/galera_end.inc - diff --git a/mysql-test/suite/galera/t/galera_schema_dirty_reads.test b/mysql-test/suite/galera/t/galera_schema_dirty_reads.test new file mode 100644 index 0000000000000000000000000000000000000000..93e24244611c931802e75fba4f1ff9da02c7b71d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_schema_dirty_reads.test @@ -0,0 +1,13 @@ +# +# Dirty reads from INFORMATION_SCHEMA tables. +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--disable_info +USE information_schema; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; +SET GLOBAL wsrep_reject_queries=ALL; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; +SET GLOBAL wsrep_reject_queries=NONE; +SET SESSION wsrep_dirty_reads=TRUE; +SELECT * FROM SESSION_VARIABLES WHERE VARIABLE_NAME LIKE "wsrep_dirty_reads"; diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf b/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf new file mode 100644 index 0000000000000000000000000000000000000000..336296e9bfed5394367e3adecd5cc89788788142 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf @@ -0,0 +1,16 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=mariabackup +wsrep_sst_auth="root:" +wsrep_debug=ON + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT +streamfmt=xbstream diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup.test b/mysql-test/suite/galera/t/galera_sst_mariabackup.test new file mode 100644 index 0000000000000000000000000000000000000000..bcb9ade3a25a27a364195449210cec08f023ba0d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup.test @@ -0,0 +1,20 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_mariabackup.inc + +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc + +# Restore original auto_increment_offset values. +--source include/auto_increment_offset_restore.inc + +--source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump.test b/mysql-test/suite/galera/t/galera_sst_mysqldump.test index 0b7171597dd8a4862ab2323b802b86683a9b4a03..835fac94a683cfb393db3259cb5da17656abaa73 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump.test +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump.test @@ -1,9 +1,12 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_innodb.inc --source suite/galera/include/galera_sst_set_mysqldump.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --source suite/galera/include/galera_st_disconnect_slave.inc # We set the required mysqldump SST options here so that they are used every time the server is restarted during the test @@ -15,4 +18,5 @@ --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc --source suite/galera/include/galera_sst_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf index e108484b24865093f042a6679993b43bfefa25c8..44e5573b3e6d16cadbe1f5f1a026bb97111acb81 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf @@ -12,10 +12,6 @@ wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore [mysqld] wsrep_debug=ON -ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem -ssl-cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem -ssl-key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem - [client] ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem ssl-cert=@ENV.MYSQL_TEST_DIR/std_data/client-cert.pem diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test index c813e04169f994be8a0378c7a6090e9defb076be..0dbc63b531c44ff3ebb7b854a0a2b7e1b3952544 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test @@ -5,9 +5,12 @@ --source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc ---source include/have_openssl.inc +--source include/have_ssl_communication.inc --source suite/galera/include/galera_sst_set_mysqldump.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 CREATE USER sslsst; @@ -18,12 +21,7 @@ SET GLOBAL wsrep_sst_auth = 'sslsst:'; --source suite/galera/include/galera_st_disconnect_slave.inc +--source include/auto_increment_offset_restore.inc --source suite/galera/include/galera_sst_restore.inc -DROP USER sslsst; - ---connection node_2 -# We have to manually restore global_log and slow_query_log due to mysql-wsrep#108 -# Otherwise MTR's check_testcases complains -SET GLOBAL general_log = ON; -SET GLOBAL slow_query_log = ON; +DROP USER sslsst; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync.test b/mysql-test/suite/galera/t/galera_sst_rsync.test index c6823795e59d0c382ef7ddf767a12184efa4bef8..5c08707e87038c569865fd385248f0ed212d3001 100644 --- a/mysql-test/suite/galera/t/galera_sst_rsync.test +++ b/mysql-test/suite/galera/t/galera_sst_rsync.test @@ -1,9 +1,13 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_innodb.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --source suite/galera/include/galera_st_shutdown_slave.inc --source suite/galera/include/galera_st_clean_slave.inc --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf index 31bd1af07c21f7e8ea25c2033406b818e0d77cf8..3abf2549aaed597691080c2a0ef844be0250476b 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.cnf @@ -8,7 +8,7 @@ wsrep_debug=ON [xtrabackup] backup-locks close-files -compact +#compact - disabled in xtrabackup 2.4, https://bugs.launchpad.net/percona-xtrabackup/+bug/1192834/comments/29 # compression requires qpress from the Percona repositories # compress # compress-threads=2 @@ -22,3 +22,4 @@ parallel=2 encrypt=1 encrypt-algo=AES256 encrypt-key=4FA92C5873672E20FB163A0BCB2BB4A4 +transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test index 4573f176482d214127ee47cf3a880b9a87ce4290..db2b706b6b856beaba5d9d49a8638cbb1951086b 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2-options.test @@ -3,9 +3,9 @@ # Initial SST happens via xtrabackup, so there is not much to do in the body of the test # ---source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_xtrabackup.inc SELECT 1; diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf index 47cb3e0229220e1504c4452191a8e64b8c009fbb..0025b259ec52614d5defdeb4219a060b7c6257fe 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf @@ -11,3 +11,5 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test index aac6822170a862a084b330b80be2ad486fe9f037..c270e4d0b1947174c1e5393b5db90156fb620c3d 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test @@ -1,6 +1,7 @@ --source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_xtrabackup.inc # Save original auto_increment_offset values. --let $node_1=node_1 diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf index 969516f5f3b26f2a65d0a6c833b314e14f75ce13..63d05104a37fcc45b0bf5029fa30c7cc6d84c085 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.cnf @@ -9,3 +9,4 @@ wsrep_debug=ON tkey=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem tcert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem encrypt=3 +transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test index 24d9589d111b838648cd6275bc88f4dd5292db18..2f685ca7184f4eba42278bb1993e08ed93a2a0fd 100644 --- a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2_encrypt_with_key.test @@ -6,6 +6,7 @@ --source include/big_test.inc --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_xtrabackup.inc SELECT 1; diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index aa4543cf81caf76bb85a480e103e6492d7d5f674..6f0f8014397ed29b0d31c5213ad0f8faef70a96a 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -29,6 +29,11 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; exit(0); EOF +SET SESSION wsrep_sync_wait = 0; + +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + --error ER_UNKNOWN_COM_ERROR,ER_LOCK_WAIT_TIMEOUT,ER_LOCK_DEADLOCK,ER_ERROR_DURING_COMMIT INSERT INTO t1 VALUES (1); @@ -41,8 +46,6 @@ INSERT INTO t1 VALUES (1); exit(0); EOF -SET SESSION wsrep_sync_wait = 1; ---sleep 10 --source include/wait_until_ready.inc INSERT INTO t1 VALUES (1); @@ -51,7 +54,7 @@ INSERT INTO t1 VALUES (1); --source include/galera_connect.inc --connection node_2a -SET SESSION wsrep_sync_wait = 1; +SET SESSION wsrep_sync_wait = 0; --source include/wait_until_ready.inc SELECT COUNT(*) = 1 FROM t1; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test b/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test index 1f44693877512abce2955e441afec645fecb8563..9f161afc52ef026385320dc84d4ffed7a59da566 100644 --- a/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test +++ b/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test @@ -20,7 +20,7 @@ CREATE TABLE child ( parent_id INT ) ENGINE=InnoDB; -INSERT INTO parent VALUES (DEFAULT, 0); +INSERT INTO parent VALUES (1, 0); --connection node_2 --send INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test index 821f7a6eb2cc13abe48e86d14f07f2af65d89697..dbd2510cba3cba75b09dc45d0885b1b0af6bc5c1 100644 --- a/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test +++ b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test @@ -17,12 +17,23 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); --reap INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 234); +--let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; SELECT COUNT(*) = 2 FROM t1; --connection node_1 --reap + +--let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; SELECT COUNT(*) = 2 FROM t1; diff --git a/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.opt b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.opt new file mode 100644 index 0000000000000000000000000000000000000000..0a03610888cbf0e8f202d633cefe6a4a4f38b46a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.opt @@ -0,0 +1 @@ +--wsrep-auto-increment-control=ON diff --git a/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test index d65a35be4d132d0026c2cf3bd41931c17ed618f7..ee31be94edd7edbaae6eae13395f9372e924299c 100644 --- a/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test +++ b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test @@ -9,13 +9,17 @@ CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB; +--let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset` # auto_increment_increment is equal to the number of nodes -# auto_increment_offset is equal to the ID of the node - SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); -SELECT @@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; + +--connection node_2 +--disable_query_log +--eval SELECT @@global.auto_increment_offset != $auto_increment_offset_node_1 AS auto_increment_offset_differ; +--enable_query_log # Expect no conflicts +--connection node_1 --send INSERT INTO t1 VALUES (DEFAULT, 'node1'); --connection node_2 @@ -27,10 +31,18 @@ SELECT @@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_ --connection node_2 --reap +--let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset` +# auto_increment_increment is equal to the number of nodes SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); -SELECT @@global.auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; + +--connection node_1 +--disable_query_log +--eval SELECT @@global.auto_increment_offset != $auto_increment_offset_node_2 AS auto_increment_offset_differ; +--enable_query_log + # Expect no conflicts +--connection node_2 --send INSERT INTO t1 VALUES (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'); --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_var_cluster_address.test b/mysql-test/suite/galera/t/galera_var_cluster_address.test index 03706bbbb120c789c352781d99094ba9a4dfea11..6d99d35cdac2418115e738457b078466b8a7a34c 100644 --- a/mysql-test/suite/galera/t/galera_var_cluster_address.test +++ b/mysql-test/suite/galera/t/galera_var_cluster_address.test @@ -24,7 +24,6 @@ SET GLOBAL wsrep_cluster_address = 'foo://'; SET SESSION wsrep_sync_wait=0; ---error ER_UNKNOWN_COM_ERROR SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS; # Must return 'OFF' diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index cba8488b8791087901a86b8305468486a15291af..1f01c4aac07232476d169c8a1d5dc3e6b3d557ab 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -4,6 +4,12 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_perfschema.inc + +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc # Save original auto_increment_offset values. --let $node_1=node_1 @@ -49,13 +55,10 @@ SELECT i, variable_name, variable_value FROM t1, information_schema.session_vari SELECT 1; ---error ER_UNKNOWN_COM_ERROR USE information_schema; ---error ER_UNKNOWN_COM_ERROR SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; ---error ER_UNKNOWN_COM_ERROR SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; --disable_query_log diff --git a/mysql-test/suite/galera/t/galera_var_node_address.test b/mysql-test/suite/galera/t/galera_var_node_address.test index 3353652d8b9471b0be02d97d33976391a6a6f32e..22e98e3aa82baba7fd1908dab38084427816e9b9 100644 --- a/mysql-test/suite/galera/t/galera_var_node_address.test +++ b/mysql-test/suite/galera/t/galera_var_node_address.test @@ -8,6 +8,7 @@ call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); +call mtr.add_suppression("WSREP: Sending JOIN failed: -[0-9]+ (Transport endpoint is not connected). Will retry in new primary component."); SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; diff --git a/mysql-test/suite/galera/t/galera_var_reject_queries.test b/mysql-test/suite/galera/t/galera_var_reject_queries.test new file mode 100644 index 0000000000000000000000000000000000000000..6859855c35f1e650db3c8dac739e4532d31713b1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_reject_queries.test @@ -0,0 +1,44 @@ +# +# Test wsrep_reject_queries +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER); + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +--connection node_1 +--error ER_GLOBAL_VARIABLE +SET SESSION wsrep_reject_queries = ALL; + +SET GLOBAL wsrep_reject_queries = ALL; + +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM t1; + +# Lost connection +--error 2013 +SET GLOBAL wsrep_reject_queries = ALL_KILL; + +--connection node_1a +--error ER_CONNECTION_KILLED,2013,2006 +SELECT * FROM t1; + +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM t1; + +# Confirm that replication continues + +--connection node_2 +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +INSERT INTO t1 VALUES (1); + +--connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET GLOBAL wsrep_reject_queries = NONE; + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test index bf4da3234c54aa8e341b9dfa4a3e6135fd136fef..142f02546b4853f3313dc68aa531c035de123b66 100644 --- a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test +++ b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test @@ -1,98 +1,141 @@ # -# Test that the wsrep_retry_autocommit variable is respected. We use an INSERT that -# proceeds very slowly due to extra SLEEP() in a trigger +# Test that the wsrep_retry_autocommit variable is respected. # --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_debug_sync.inc ---connection node_1 -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; -CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 # # With wsrep_retry_autocommit = 0, error is certain # --connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + SET SESSION wsrep_retry_autocommit = 0; ---send INSERT INTO t1 (f1) VALUES (1),(2); +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +--send INSERT INTO t1 (f1) VALUES (2) + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; --connection node_2 ---sleep 1 TRUNCATE TABLE t1; --connection node_1 --error ER_LOCK_DEADLOCK --reap +SELECT COUNT(*) = 0 FROM t1; + +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; + # # With wsrep_retry_autocommit = 1, success against one TRUNCATE # --connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + SET SESSION wsrep_retry_autocommit = 1; ---send INSERT INTO t1 (f1) VALUES (3),(4); +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +--send INSERT INTO t1 (f1) VALUES (2) + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; --connection node_2 ---sleep 1 TRUNCATE TABLE t1; --connection node_1 ---error 0 --reap -SELECT * FROM test.t1; +SELECT COUNT(*) = 1 FROM t1; + +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; + # -# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs +# With wsrep_retry_autcommit = 1, failure against multiple TRUNCATEs # +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +SET SESSION wsrep_retry_autocommit = 1; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 2'; + +--send INSERT INTO t1 VALUES (2); + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; + --connection node_2 -DELIMITER |; -CREATE PROCEDURE repeated_truncate () -BEGIN - DECLARE i INT; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; - - SET i = 0; - WHILE i <= 1000 DO - TRUNCATE TABLE t1; - SET i = i + 1; - END WHILE; -END| -DELIMITER ;| - -# Begin streaming TRUNCATEs ---let $truncate_connection_id = `SELECT CONNECTION_ID()` ---send CALL repeated_truncate() +TRUNCATE TABLE t1; + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; +SELECT COUNT(*) = 0 FROM t1; +SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_rep'; + +--connection node_2 +TRUNCATE TABLE t1; + +--connection node_1a +SELECT COUNT(*) = 0 FROM t1; --connection node_1 -SET SESSION wsrep_retry_autocommit = 1; ---sleep 1 --error ER_LOCK_DEADLOCK -INSERT INTO t1 (f1) VALUES (5),(6); +--reap + +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; +DROP TABLE t1; + # -# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs +# With wsrep_retry_autocommit = 64, success against 64 TRUNCATEs # --connection node_1 -SET SESSION wsrep_retry_autocommit = 1024; ---send INSERT INTO t1 (f1) VALUES (7),(8); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; ---sleep 6 +SET SESSION wsrep_retry_autocommit = 64; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 64'; -# Once he stream of TRUNCATEs is complete ---connection node_2 ---reap +--send INSERT INTO t1 VALUES (2) + +--disable_query_log +--disable_result_log +--let $count = 64 +while ($count) +{ + --connection node_1a + SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; + + --connection node_2 + TRUNCATE TABLE t1; + + --connection node_1a + SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; + SELECT COUNT(*) = 1 FROM t1; + SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue'; + + --dec $count +} +--enable_result_log +--enable_query_log -# the INSERT will eventually be sucessfull --connection node_1 ---error 0 --reap +SELECT COUNT(*) = 1 FROM t1; ---let $diff_servers = 1 2 ---source include/diff_servers.inc - +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; DROP TABLE t1; -DROP PROCEDURE repeated_truncate; diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test index 5e56800c5d6a3f8c8e941b9b846df4028b952b4f..0afda948ed51ab13cb8d1a2367e796c4c536084a 100644 --- a/mysql-test/suite/galera/t/galera_var_slave_threads.test +++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test @@ -6,7 +6,6 @@ --source include/galera_cluster.inc --source include/have_innodb.inc -CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); --let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` --connection node_1 @@ -14,7 +13,7 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; --connection node_2 - +CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread."); # Setting wsrep_slave_threads to zero triggers a warning SET GLOBAL wsrep_slave_threads = 0; SHOW WARNINGS; @@ -30,15 +29,14 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use # SET GLOBAL wsrep_slave_threads = 64; ---sleep 0.5 --connection node_1 INSERT INTO t1 VALUES (1); --connection node_2 SELECT COUNT(*) = 1 FROM t1; - -SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; # @@ -59,8 +57,8 @@ while ($count) --connection node_2 SELECT COUNT(*) = 64 FROM t2; - -SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +--source include/wait_condition.inc SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; @@ -78,7 +76,30 @@ CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB; --connection node_2 SET GLOBAL wsrep_slave_threads = 4; +--let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' +--source include/wait_condition.inc + SET GLOBAL wsrep_slave_threads = 1; + +--connection node_1 +INSERT INTO t1 VALUES (DEFAULT); +INSERT INTO t1 VALUES (DEFAULT); +INSERT INTO t1 VALUES (DEFAULT); DROP TABLE t1; +--connection node_2 + +# Wait until above DDL is replicated +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; + +# +# make sure that we are left with exactly one applier thread before we leaving the test +# +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' +--source include/wait_condition.inc +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; + --echo # End of tests diff --git a/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test b/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test index 3c7988a4924e52c07d7617a0930eb150554f0d1d..ecf255f59c3ad40fa16533b75da8924c26ac087d 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test +++ b/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test @@ -17,6 +17,8 @@ CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; --connection node_2 +SELECT COUNT(*) = 100000 FROM t1; + SET GLOBAL wsrep_desync = TRUE; SET SESSION wsrep_on = FALSE; diff --git a/mysql-test/suite/galera/t/lp1376747-2.test b/mysql-test/suite/galera/t/lp1376747-2.test index 360681d7674fd79bce10097733d315e47e8352ab..c570dd7d14331ad7cd415cacdd84524cfc184254 100644 --- a/mysql-test/suite/galera/t/lp1376747-2.test +++ b/mysql-test/suite/galera/t/lp1376747-2.test @@ -5,6 +5,13 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); --connection node_2 + +# Wait until above DDL's are replicated +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; + FLUSH TABLES t1 FOR EXPORT; --connection node_1 diff --git a/mysql-test/suite/galera/t/lp1376747.test b/mysql-test/suite/galera/t/lp1376747.test index 769bb665c7766f1fac8491afe39c22b2d99a7ec8..7daa544686fb435a918efef9d4743dcfcc36e432 100644 --- a/mysql-test/suite/galera/t/lp1376747.test +++ b/mysql-test/suite/galera/t/lp1376747.test @@ -5,6 +5,13 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); --connection node_2 + +# Wait until above DDL's are replicated +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%'; + FLUSH TABLES t1 WITH READ LOCK; --connection node_1 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#33.test b/mysql-test/suite/galera/t/mysql-wsrep#33.test index acc7c735849710ac2a08964a94a27b4547234653..351e457f16504f7f35b79d3047f0cddcf15ee329 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#33.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#33.test @@ -3,6 +3,9 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source suite/galera/include/auto_increment_offset_save.inc --source suite/galera/include/galera_sst_set_mysqldump.inc --source suite/galera/include/galera_st_disconnect_slave.inc @@ -10,9 +13,8 @@ --source suite/galera/include/galera_sst_restore.inc --connection node_2 -# We have to manually restore global_log and slow_query_log due to mysql-wsrep#108 -# Otherwise MTR's check_testcases complains -SET GLOBAL general_log = ON; -SET GLOBAL slow_query_log = ON; +--echo Restarting server ... +--source include/restart_mysqld.inc +--source suite/galera/include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/mysql-wsrep#90.test b/mysql-test/suite/galera/t/mysql-wsrep#90.test index 5af86fb28722992026f72d8f85d9e2cd6ae50462..11ef64165263708b918189749b0adafc0610a304 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#90.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#90.test @@ -31,6 +31,7 @@ SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; --connection node_1 DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; @@ -63,3 +64,4 @@ INSERT INTO t1 VALUES (3,4); DROP TABLE t1; SET GLOBAL WSREP_OSU_METHOD = TOI; +SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/galera/t/pxc-421.test b/mysql-test/suite/galera/t/pxc-421.test index 381f9bb44947866a7a7c338ce61070da22d0ccdf..33a2b157f18a4fa63a918fdc2a32e720683370c3 100644 --- a/mysql-test/suite/galera/t/pxc-421.test +++ b/mysql-test/suite/galera/t/pxc-421.test @@ -6,6 +6,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 --let $wsrep_slave_1 = `SELECT @@wsrep_slave_threads` set GLOBAL wsrep_slave_threads=26; @@ -31,9 +36,7 @@ INSERT INTO t1 VALUES (3); --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log -set SESSION wsrep_sync_wait=0; --source include/wait_until_connected_again.inc ---source include/galera_wait_ready.inc INSERT INTO t1 VALUES (4); set GLOBAL wsrep_slave_threads=5; @@ -54,12 +57,11 @@ show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2 SELECT COUNT(*) FROM t1; -SET GLOBAL auto_increment_offset = 2; - --connection node_1 SELECT COUNT(*) FROM t1; show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1 DROP TABLE t1; -SET GLOBAL auto_increment_offset = 1; +--source include/auto_increment_offset_restore.inc + diff --git a/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result b/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result index 1464222a079c40cc680ad2ee74634e20b003ce2f..7e0d282ec7ff266adda5489ea5ef5f4236c87867 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result +++ b/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result @@ -11,6 +11,7 @@ SET SESSION wsrep_sync_wait = 0; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 +SET SESSION wsrep_sync_wait = DEFAULT; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test b/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test index a87f19ac94ebde02e6aa2c5e89be7482fade7c28..03236a3cb9366aab2c39bd279e534e8b6efb8761 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test +++ b/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test @@ -50,6 +50,7 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --enable_query_log --source include/wait_until_connected_again.inc +SET SESSION wsrep_sync_wait = DEFAULT; SELECT COUNT(*) = 1 FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test index c118b7481bca2a3714afc6bf4dc29bd4ae3a9d83..d69881aa5ebfb4ab20a1f282b578b7b2af0f9a25 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test +++ b/mysql-test/suite/galera_3nodes/t/galera_pc_weight.test @@ -9,16 +9,12 @@ --connection node_1 SET GLOBAL wsrep_provider_options = 'pc.weight=3'; - ---source include/wait_until_connected_again.inc --source include/galera_suspend.inc --sleep 10 --connection node_2 # Do not wait for causality as we are no longer in the primary component SET SESSION wsrep_sync_wait=0; ---source include/wait_until_connected_again.inc - SET SESSION wsrep_on=OFF; --let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' --source include/wait_condition.inc @@ -39,7 +35,6 @@ SHOW STATUS LIKE 'wsrep_local_state_comment'; --source include/galera_connect.inc --connection node_3 SET SESSION wsrep_sync_wait=0; ---source include/wait_until_connected_again.inc SHOW STATUS LIKE 'wsrep_cluster_size'; SHOW STATUS LIKE 'wsrep_cluster_status'; diff --git a/mysql-test/suite/handler/handler.inc b/mysql-test/suite/handler/handler.inc index c71dc53e5accc9cfd82409d9b1411e78e6212edd..25c72965c0be1163a726fa8254059c65cddcf4ee 100644 --- a/mysql-test/suite/handler/handler.inc +++ b/mysql-test/suite/handler/handler.inc @@ -377,7 +377,9 @@ send optimize table t1; # client 1 --echo proceed with the normal connection connection default; +--disable_ps_protocol handler t1 read next; +--enable_ps_protocol handler t1 close; # client 2 --echo read the result from the other connection diff --git a/mysql-test/suite/handler/interface.result b/mysql-test/suite/handler/interface.result index 89dec29f412ba0b4728f1dad67ca1b8f7134b66f..c9cffba33f723b1e0cb10043a7bc68745b8b99e5 100644 --- a/mysql-test/suite/handler/interface.result +++ b/mysql-test/suite/handler/interface.result @@ -269,7 +269,7 @@ handler t1 open; lock table t1 write; alter table t1 engine=csv; handler t1 read a next; -ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option +Got one of the listed errors handler t1 close; unlock tables; drop table t1; diff --git a/mysql-test/suite/handler/interface.test b/mysql-test/suite/handler/interface.test index 2ef617c3ce7f2e5b4735bbccefae2f7b87968ada..06797ed69806a94cf58b9baa033dac449138b755 100644 --- a/mysql-test/suite/handler/interface.test +++ b/mysql-test/suite/handler/interface.test @@ -326,7 +326,7 @@ let $wait_condition= info = "alter table t1 engine=csv"; --source include/wait_condition.inc connection default; ---error ER_ILLEGAL_HA +--error ER_ILLEGAL_HA,ER_KEY_DOES_NOT_EXITS handler t1 read a next; handler t1 close; connection con1; diff --git a/mysql-test/suite/handler/ps.result b/mysql-test/suite/handler/ps.result new file mode 100644 index 0000000000000000000000000000000000000000..54685f9156b8f0ac5f4ab40ef721ccff16e5349d --- /dev/null +++ b/mysql-test/suite/handler/ps.result @@ -0,0 +1,9 @@ +create table t1 (i int); +handler test.t1 open handler_a; +flush status; +handler handler_a read first; +i +show status like 'Com_stmt_prepare%'; +Variable_name Value +Com_stmt_prepare OK +drop table t1; diff --git a/mysql-test/suite/handler/ps.test b/mysql-test/suite/handler/ps.test new file mode 100644 index 0000000000000000000000000000000000000000..68091190c85948fa940cffe004733b95b51c3255 --- /dev/null +++ b/mysql-test/suite/handler/ps.test @@ -0,0 +1,11 @@ +# +# MDEV-15729 Server crashes in Field::make_field upon HANDLER READ executed with PS protocol +# +create table t1 (i int); +handler test.t1 open handler_a; +flush status; +handler handler_a read first; +# handler...read must be prepared in --ps-protocol mode +--replace_result $PS_PROTOCOL OK +show status like 'Com_stmt_prepare%'; +drop table t1; diff --git a/mysql-test/suite/innodb/r/alter_partitioned_xa.result b/mysql-test/suite/innodb/r/alter_partitioned_xa.result new file mode 100644 index 0000000000000000000000000000000000000000..4bce2f8676fa0787d01d2233e1b708c8245f12da --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_partitioned_xa.result @@ -0,0 +1,15 @@ +# +# MDEV-14693 XA: Assertion `!clust_index->online_log' failed +# in rollback_inplace_alter_table +# +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2; +XA START 'xid'; +INSERT INTO t1 VALUES (1,10); +CREATE DATABASE IF NOT EXISTS db; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state +SET innodb_lock_wait_timeout= 1, lock_wait_timeout= 2; +ALTER TABLE t1 FORCE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +XA END 'xid'; +XA ROLLBACK 'xid'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/create-index-debug.result b/mysql-test/suite/innodb/r/create-index-debug.result index 99f6efe9bfe0cd139873b021289a659e8611bfb7..9d266c68af335d361e94e0d0c7b7d22b0293220a 100644 --- a/mysql-test/suite/innodb/r/create-index-debug.result +++ b/mysql-test/suite/innodb/r/create-index-debug.result @@ -10,9 +10,6 @@ CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 CHAR(255) NOT NULL) ENGINE=INNODB ROW_FORMAT=DYNAMIC; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. INSERT INTO t1 VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); INSERT INTO t1 SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/r/default_row_format_alter.result b/mysql-test/suite/innodb/r/default_row_format_alter.result new file mode 100644 index 0000000000000000000000000000000000000000..1f4f78ee67000ab3963a65777caca14984a5fbf8 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_alter.result @@ -0,0 +1,85 @@ +SET @row_format = @@GLOBAL.innodb_default_row_format; +#################################### +# Check if table rebuilding alter isn't affect if table is created +# with explicit row_format +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; +# Here we expect COMPACT because it was explicitly specified at CREATE +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +DROP TABLE t1; +#################################### +# Check if table rebuilding alter is affected when there is no +# row_format specified at CREATE TABLE. +SET GLOBAL innodb_default_row_format = COMPACT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innodb_default_row_format = DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; +# Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the +# default_row_format is changed to DYNAMIC just before ALTER +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +#################################### +# Check the row_format effect on ALTER, ALGORITHM=COPY +SET GLOBAL innodb_default_row_format = REDUNDANT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't +# created with explicit row_format, so we expect ROW_FORMAT=COMPACT +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; + +################################### +# Check the row_format effect on ALTER, ALGORITH=COPY on +# create table with explicit row_format +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is +# created with explicit row_format, so we expect original +# ROW_FORMAT=REDUNDANT +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +DROP TABLE t1; + +################################## +# Check row_format on ALTER ALGORITHM=INPLACE +SET GLOBAL innodb_default_row_format=COMPACT; +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP INDEX k1; +# Because it is in-place operation, there is no rebuild, so the +# original format has to be retained. +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +SET GLOBAL innodb_default_row_format = @row_format; diff --git a/mysql-test/suite/innodb/r/default_row_format_compatibility.result b/mysql-test/suite/innodb/r/default_row_format_compatibility.result new file mode 100644 index 0000000000000000000000000000000000000000..6ba83f04136b7fe1da00beb7fb042c0fbc663681 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_compatibility.result @@ -0,0 +1,103 @@ +SET @row_format = @@GLOBAL.innodb_default_row_format; +SET @large_prefix = @@GLOBAL.innodb_large_prefix; +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_file_format = barracuda; +# ########################################################### +# Check with Import/Export tablespace with Default_row_format +SET GLOBAL innodb_default_row_format=Compact; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +SELECT @@innodb_file_per_table; +@@innodb_file_per_table +1 +CREATE TABLE tab(a INT) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab VALUES(1); +INSERT INTO tab VALUES(2); +SELECT * FROM tab; +a +1 +2 +FLUSH TABLE tab FOR EXPORT; +UNLOCK TABLES; +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Dynamic; +CREATE TABLE tab(a INT) ENGINE=InnoDB; +ALTER TABLE tab DISCARD TABLESPACE; +ALTER TABLE tab IMPORT TABLESPACE; +ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1) +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Compact; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +CREATE TABLE tab(a INT) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +ALTER TABLE tab DISCARD TABLESPACE; +call mtr.add_suppression("InnoDB: Tried to read .* bytes at offset 0"); +ALTER TABLE tab IMPORT TABLESPACE; +ERROR HY000: Internal error: Cannot reset LSNs in table '"test"."tab"' : I/O error +ALTER TABLE tab IMPORT TABLESPACE; +SELECT * FROM tab; +a +1 +2 +DROP TABLE tab; +# ########################################################### +SET GLOBAL innodb_default_row_format=Dynamic; +SET GLOBAL innodb_large_prefix=ON; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +dynamic +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); +SELECT * FROM tab; +a b +1 Check with max column size +SET GLOBAL innodb_default_row_format=COMPACT; +ALTER TABLE tab ROW_FORMAT=COMPACT; +ERROR HY000: Index column size too large. The maximum column size is 767 bytes. +DROP TABLE tab; +SET GLOBAL innodb_default_row_format=Default; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format=Dynamic; +SELECT @@innodb_default_row_format; +@@innodb_default_row_format +dynamic +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=COMPACT; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=COMPRESSED; +SELECT * FROM tab; +a b +1 Check with max column size +ALTER TABLE tab ROW_FORMAT=Dynamic; +SHOW TABLE STATUS LIKE 'tab'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +tab InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=DYNAMIC +DROP TABLE tab; +SET GLOBAL innodb_default_row_format = @row_format; +SET GLOBAL innodb_large_prefix = @large_prefix; +SET GLOBAL innodb_file_format = @file_format; diff --git a/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff b/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..bb23b78213b712a404f4285aa1b0f52a183f2f3c --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create,dynamic.rdiff @@ -0,0 +1,11 @@ +--- default_row_format_create.result ++++ default_row_format_create,dynamic.result +@@ -1,7 +1,7 @@ + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; + SHOW TABLE STATUS LIKE 't1'; + Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +-t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL ++t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL + DROP TABLE t1; + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + SHOW TABLE STATUS LIKE 't1'; diff --git a/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff b/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff new file mode 100644 index 0000000000000000000000000000000000000000..35aa402edd9a0ef741172e0ce201e57b101a0ca1 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create,redundant.rdiff @@ -0,0 +1,11 @@ +--- default_row_format_create.result ++++ default_row_format_create,redundant.result +@@ -1,7 +1,7 @@ + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; + SHOW TABLE STATUS LIKE 't1'; + Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +-t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL ++t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL + DROP TABLE t1; + CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + SHOW TABLE STATUS LIKE 't1'; diff --git a/mysql-test/suite/innodb/r/default_row_format_create.result b/mysql-test/suite/innodb/r/default_row_format_create.result new file mode 100644 index 0000000000000000000000000000000000000000..4e90922d70db91a9f32092fb6af3e6d2ab861739 --- /dev/null +++ b/mysql-test/suite/innodb/r/default_row_format_create.result @@ -0,0 +1,31 @@ +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +Warnings: +Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope. +Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=1. +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPRESSED key_block_size=1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/file_format_defaults.result b/mysql-test/suite/innodb/r/file_format_defaults.result new file mode 100644 index 0000000000000000000000000000000000000000..981188f00f7feeca4a5ec896ebb5ef148667f841 --- /dev/null +++ b/mysql-test/suite/innodb/r/file_format_defaults.result @@ -0,0 +1,56 @@ +SELECT @@innodb_strict_mode; +@@innodb_strict_mode +0 +SELECT @@innodb_file_per_table; +@@innodb_file_per_table +1 +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_large_prefix=ON; +SET SQL_MODE=strict_all_tables; +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +SHOW CREATE TABLE tab0; +Table Create Table +tab0 CREATE TABLE `tab0` ( + `c1` varchar(65530) DEFAULT NULL, + KEY `c1` (`c1`(3072)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED +DROP TABLE tab0; +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB KEY_BLOCK_SIZE=2; +ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline. +SET GLOBAL innodb_file_format=Antelope; +CREATE TABLE tab0(c1 INT,c2 LONGBLOB ) ENGINE=InnoDB ROW_FORMAT=Dynamic; +DROP TABLE tab0; +SET GLOBAL innodb_file_format=Default; +SELECT @@innodb_file_format; +@@innodb_file_format +Antelope +SET GLOBAL innodb_strict_mode=OFF; +SET GLOBAL innodb_strict_mode=Default; +SELECT @@innodb_strict_mode; +@@innodb_strict_mode +0 +SET GLOBAL innodb_large_prefix=OFF; +SELECT @@innodb_large_prefix; +@@innodb_large_prefix +0 +SET GLOBAL innodb_large_prefix=Default; +SELECT @@innodb_large_prefix; +@@innodb_large_prefix +0 +SET GLOBAL innodb_file_format_max=Default; +SELECT @@innodb_file_format_max; +@@innodb_file_format_max +Antelope +CREATE TABLE tab1(c1 int ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +SELECT @@innodb_file_format_max; +@@innodb_file_format_max +Antelope +SET GLOBAL innodb_file_format_max=Default; +SET GLOBAL innodb_large_prefix=off; +SET GLOBAL innodb_file_format = @file_format; +DROP TABLE tab1; diff --git a/mysql-test/suite/innodb/r/innodb-alter-nullable.result b/mysql-test/suite/innodb/r/innodb-alter-nullable.result index e9711b2ac31bd5e590e68f5c2df30c3776071d3e..2769bfdf1f56045783143ce742601250a3308a60 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-nullable.result +++ b/mysql-test/suite/innodb/r/innodb-alter-nullable.result @@ -51,3 +51,7 @@ WHERE NAME='test/t'; TABLE_ID NAME FLAG N_COLS SPACE FILE_FORMAT ROW_FORMAT ZIP_PAGE_SIZE # test/t 1 6 # Antelope Compact 0 DROP TABLE t; +CREATE TABLE t1(c1 INT) ENGINE=InnoDB; +ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1); +ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index fadbcce332ad687e96833257587dab7bf295fa9a..d41df53e5a7fae4d6e15e1e938561e08ae69b449 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -859,3 +859,32 @@ DROP TABLE dest_db.t1; DROP TABLE source_db.t1; DROP DATABASE source_db; DROP DATABASE dest_db; +# +# BUG #26334149 MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES ARE +# ORPHANED DUE TO RENAME TABLE +# +CREATE DATABASE db1; +USE db1; +CREATE TABLE notes ( +id int(11) NOT NULL AUTO_INCREMENT, +body text COLLATE utf8_unicode_ci, +PRIMARY KEY (id) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci +ROW_FORMAT=COMPRESSED; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +ALTER TABLE notes ADD FULLTEXT INDEX index_ft_body (body(255)); +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +DROP INDEX index_ft_body ON notes; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +CREATE DATABASE db2; +RENAME TABLE db1.notes TO db2.notes; +DROP DATABASE db1; +DROP DATABASE db2; diff --git a/mysql-test/suite/innodb/r/innodb-blob.result b/mysql-test/suite/innodb/r/innodb-blob.result index eca779724001c72efba34289ae807bdce5a6d6d0..5d2101d8eeb790c03cac9284724b24c430936d7b 100644 --- a/mysql-test/suite/innodb/r/innodb-blob.result +++ b/mysql-test/suite/innodb/r/innodb-blob.result @@ -1,3 +1,4 @@ +FLUSH TABLES; CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_default.result b/mysql-test/suite/innodb/r/innodb-page_compression_default.result index 18f7fb5e04a89b34439220c9184a26ca15e45272..19d0a875ce6cdbdfaf7d917670a7ea00b5874746 100644 --- a/mysql-test/suite/innodb/r/innodb-page_compression_default.result +++ b/mysql-test/suite/innodb/r/innodb-page_compression_default.result @@ -1,4 +1,3 @@ -call mtr.add_suppression("InnoDB: Compression failed for space [0-9]+ name test/innodb_page_compressed[0-9] len [0-9]+ err 2 write_size [0-9]+."); set global innodb_file_format = `Barracuda`; set global innodb_file_per_table = on; create table innodb_normal (c1 int not null auto_increment primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result b/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result index 74cfa9bce3a0f7c308933f19580efd99f2451b64..824b671eea3150060604c348eeb89238937f6d88 100644 --- a/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result +++ b/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result @@ -1,4 +1,3 @@ -call mtr.add_suppression("InnoDB: Compression failed for space [0-9]+ name test/innodb_page_compressed[0-9] len [0-9]+ err 2 write_size [0-9]+."); set global innodb_compression_algorithm = snappy; set global innodb_file_format = `Barracuda`; set global innodb_file_per_table = on; diff --git a/mysql-test/suite/innodb/r/innodb_bug27216817.result b/mysql-test/suite/innodb/r/innodb_bug27216817.result new file mode 100644 index 0000000000000000000000000000000000000000..0210ced9f9111865cfb8bd6e02d3ab44e2b8877d --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug27216817.result @@ -0,0 +1,24 @@ +create table t1 (a int not null, b int not null) engine=innodb; +insert t1 values (1,2),(3,4); +lock table t1 write, t1 tr read; +flush status; +alter table t1 add primary key (b); +show status like 'Handler_read_rnd_next'; +Variable_name Value +Handler_read_rnd_next 0 +unlock tables; +alter table t1 drop primary key; +lock table t1 write; +flush status; +alter table t1 add primary key (b); +show status like 'Handler_read_rnd_next'; +Variable_name Value +Handler_read_rnd_next 0 +unlock tables; +alter table t1 drop primary key; +flush status; +alter table t1 add primary key (b); +show status like 'Handler_read_rnd_next'; +Variable_name Value +Handler_read_rnd_next 0 +drop table t1; diff --git a/mysql-test/suite/innodb/r/innodb_bug54044.result b/mysql-test/suite/innodb/r/innodb_bug54044.result index 7d6133adb74e8485934685c4d83ac9170448ac1f..29b0127f20b9221e028c5850e13619de4d87153c 100644 --- a/mysql-test/suite/innodb/r/innodb_bug54044.result +++ b/mysql-test/suite/innodb/r/innodb_bug54044.result @@ -16,9 +16,3 @@ tmp CREATE TABLE `tmp` ( `NULL` binary(0) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE tmp; -CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB; -INSERT INTO t1 VALUES ('foo'),('bar'); -FLUSH TABLES; -CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT VALUES(a) FROM t1; -ERROR HY000: Can't create table `test`.`tmp` (errno: -1 "Internal error < 0 (Not system error)") -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_defragment_small.result b/mysql-test/suite/innodb/r/innodb_defragment_small.result index 3f594f79e70281c5af83836d7ba2ba30e398611d..07e58f442d990de145c7e1ec0b399fc7393f22e8 100644 --- a/mysql-test/suite/innodb/r/innodb_defragment_small.result +++ b/mysql-test/suite/innodb/r/innodb_defragment_small.result @@ -1,6 +1,13 @@ SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment; +SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only; SET GLOBAL innodb_defragment = 1; -CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB; +SET GLOBAL innodb_optimize_fulltext_only = 0; +# +# MDEV-12198 innodb_defragment=1 crashes server on +# OPTIMIZE TABLE when FULLTEXT index exists +# +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), +KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB; OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK @@ -11,14 +18,18 @@ INSERT INTO t1 VALUES (400000, REPEAT('A', 256)); OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK -DROP TABLE t1; # -# MDEV-12198 innodb_defragment=1 crashes server on -# OPTIMIZE TABLE when FULLTEXT index exists +# MDEV-15824 innodb_defragment=ON trumps +# innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE # -CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB; +SET GLOBAL innodb_optimize_fulltext_only = 1; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SET GLOBAL innodb_defragment = 0; OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; SET GLOBAL innodb_defragment = @innodb_defragment_orig; +SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig; diff --git a/mysql-test/suite/innodb/r/lock_deleted.result b/mysql-test/suite/innodb/r/lock_deleted.result new file mode 100644 index 0000000000000000000000000000000000000000..d949ac945de5f8ec21ca57173adeb16d9240b2d0 --- /dev/null +++ b/mysql-test/suite/innodb/r/lock_deleted.result @@ -0,0 +1,40 @@ +START TRANSACTION WITH CONSISTENT SNAPSHOT; +CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1,1); +DELETE FROM t1; +SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked'; +BEGIN; +INSERT INTO t1 VALUES(1,1); +SET DEBUG_SYNC='now WAIT_FOR inserted'; +SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked'; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +DELETE FROM t1 WHERE b=1; +COMMIT; +SET DEBUG_SYNC='RESET'; +ROLLBACK; +SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked'; +BEGIN; +INSERT INTO t1 VALUES(1,1); +SET DEBUG_SYNC='now WAIT_FOR inserted'; +SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked'; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +BEGIN; +DELETE FROM t1 WHERE b=1; +COMMIT; +SET DEBUG_SYNC='RESET'; +ROLLBACK; +SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked'; +BEGIN; +SET innodb_lock_wait_timeout=1; +INSERT INTO t1 VALUES(1,1); +SET DEBUG_SYNC='now WAIT_FOR inserted'; +SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked'; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +DELETE FROM t1 WHERE b=1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +COMMIT; +SET DEBUG_SYNC='RESET'; +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/mvcc.result b/mysql-test/suite/innodb/r/mvcc.result new file mode 100644 index 0000000000000000000000000000000000000000..6bbabc8d87a01b715f4653407eeed1112647f50b --- /dev/null +++ b/mysql-test/suite/innodb/r/mvcc.result @@ -0,0 +1,26 @@ +SET @save_per_table= @@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table= 1; +# +# MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +FLUSH TABLES t1 WITH READ LOCK; +UNLOCK TABLES; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +ALTER TABLE t1 FORCE, ALGORITHM=COPY; +SELECT * FROM t1; +ERROR HY000: Table definition has changed, please retry transaction +COMMIT; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 IMPORT TABLESPACE; +# FIXME: Block this with ER_TABLE_DEF_CHANGED +SELECT * FROM t1; +a +COMMIT; +SELECT * FROM t1; +a +0 +DROP TABLE t1; +SET GLOBAL innodb_file_per_table= @save_per_table; diff --git a/mysql-test/suite/innodb/r/read_only_recover_committed.result b/mysql-test/suite/innodb/r/read_only_recover_committed.result new file mode 100644 index 0000000000000000000000000000000000000000..593bcae40eed6d833198950e60551c05f0f89b83 --- /dev/null +++ b/mysql-test/suite/innodb/r/read_only_recover_committed.result @@ -0,0 +1,43 @@ +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t VALUES(1); +BEGIN; +INSERT INTO t VALUES(2); +DELETE FROM t WHERE a=2; +# Normal MariaDB shutdown would roll back the above transaction. +# We want the transaction to remain open, so we will kill the server +# after ensuring that any non-transactional files are clean. +FLUSH TABLES; +# Create another transaction that will be recovered as COMMITTED. +BEGIN; +SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever'; +COMMIT; +SET DEBUG_SYNC='now WAIT_FOR committed'; +# Ensure that the above incomplete transactions become durable. +SET GLOBAL innodb_flush_log_at_trx_commit=1; +BEGIN; +INSERT INTO t VALUES(-10000); +ROLLBACK; +SELECT * FROM t; +a +1 +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +a +1 +UPDATE t SET a=3 WHERE a=1; +ERROR HY000: Table 't' is read only +# Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. +# In earlier versions, this would return the last committed version +# (empty table)! +SELECT * FROM t; +a +1 +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +a +1 +SELECT * FROM t; +a +1 +DROP TABLE t; +NOT FOUND /Rolled back recovered transaction [^0]/ in mysqld.1.err diff --git a/mysql-test/suite/innodb/r/recovery_shutdown.result b/mysql-test/suite/innodb/r/recovery_shutdown.result index 861461dd07296b9b34838508176fc741aa6fdd89..47398c1ca230e48e4b707c39ce0f98846e55315b 100644 --- a/mysql-test/suite/innodb/r/recovery_shutdown.result +++ b/mysql-test/suite/innodb/r/recovery_shutdown.result @@ -52,5 +52,5 @@ INSERT INTO t1(a) SELECT NULL FROM t1; INSERT INTO t1(a) SELECT NULL FROM t1; SET GLOBAL innodb_flush_log_at_trx_commit=1; CREATE TABLE u(a SERIAL) ENGINE=INNODB; -# Kill and restart +FLUSH TABLES; DROP TABLE t,u; diff --git a/mysql-test/suite/innodb/r/rename_table.result b/mysql-test/suite/innodb/r/rename_table.result new file mode 100644 index 0000000000000000000000000000000000000000..49ce32540913cb99e616c0ff788dd36aa9630c57 --- /dev/null +++ b/mysql-test/suite/innodb/r/rename_table.result @@ -0,0 +1,5 @@ +call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)"); +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +RENAME TABLE t1 TO non_existing_db.t1; +ERROR HY000: Error on rename of '**path-to-t1**' to '**path-to-non-existing-db-t1**' (errno: -1 "Internal error < 0 (Not system error)") +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/restart.result b/mysql-test/suite/innodb/r/restart.result new file mode 100644 index 0000000000000000000000000000000000000000..5ebd6753e8a466ab42164b47c0616a3b16f95eb9 --- /dev/null +++ b/mysql-test/suite/innodb/r/restart.result @@ -0,0 +1,26 @@ +SET GLOBAL innodb_file_format=Barracuda; +SET GLOBAL innodb_file_per_table=1; +# +# MDEV-15333 MariaDB (still) slow start +# +# FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files +# of tables with .isl file or DATA DIRECTORY attribute. +call mtr.add_suppression("\\[ERROR\\] InnoDB: Invalid flags 0x7a207879 in tablespace 2048948345"); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Error invalid tablespace flags in file '.*td\\.ibd'"); +CREATE TABLE tr(a INT)ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT +PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9; +CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC +STATS_PERSISTENT=0 DATA DIRECTORY='MYSQL_TMP_DIR'; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +COUNT(*) +1 +SELECT * FROM tr; +a +SELECT * FROM tc; +a +SELECT * FROM td; +a +DROP TABLE tr,tc,td; diff --git a/mysql-test/suite/innodb/t/alter_partitioned_xa.test b/mysql-test/suite/innodb/t/alter_partitioned_xa.test new file mode 100644 index 0000000000000000000000000000000000000000..f0883802cd66fc6be86c5b248378481a99c75a10 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_partitioned_xa.test @@ -0,0 +1,31 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +--echo # +--echo # MDEV-14693 XA: Assertion `!clust_index->online_log' failed +--echo # in rollback_inplace_alter_table +--echo # + +# A bug in meta-data locking (MDL) for XA transactions causes +# a bug in InnoDB error handling for ALTER TABLE to be triggered. +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2; +XA START 'xid'; +INSERT INTO t1 VALUES (1,10); +# XA bug: The following releases the MDL on t1! +--error ER_XAER_RMFAIL +CREATE DATABASE IF NOT EXISTS db; + +--connect (con1,localhost,root,,test) +SET innodb_lock_wait_timeout= 1, lock_wait_timeout= 2; +# Here, innodb_lock_wait_timeout would be exceeded, causing the operation +# to roll back when InnoDB is attempting to commit. +# (Instead, lock_wait_timeout should be exceeded!) +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 FORCE; + +# Cleanup +--disconnect con1 +--connection default +XA END 'xid'; +XA ROLLBACK 'xid'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test new file mode 100644 index 0000000000000000000000000000000000000000..03e6ec38060d6f2e48a002fd8d795bd655530ab4 --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_alter.test @@ -0,0 +1,98 @@ +--source include/have_innodb.inc + +SET @row_format = @@GLOBAL.innodb_default_row_format; + +--echo #################################### +--echo # Check if table rebuilding alter isn't affect if table is created +--echo # with explicit row_format +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; + +--echo # Here we expect COMPACT because it was explicitly specified at CREATE +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo #################################### +--echo # Check if table rebuilding alter is affected when there is no +--echo # row_format specified at CREATE TABLE. +SET GLOBAL innodb_default_row_format = COMPACT; +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'abc'); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format = DYNAMIC; +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; + +--echo # Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the +--echo # default_row_format is changed to DYNAMIC just before ALTER +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo #################################### +--echo # Check the row_format effect on ALTER, ALGORITHM=COPY +SET GLOBAL innodb_default_row_format = REDUNDANT; +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; + +--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't +--echo # created with explicit row_format, so we expect ROW_FORMAT=COMPACT +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo +--echo ################################### +--echo # Check the row_format effect on ALTER, ALGORITH=COPY on +--echo # create table with explicit row_format +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innoDB_default_row_format = COMPACT; +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; + +--echo # Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is +--echo # created with explicit row_format, so we expect original +--echo # ROW_FORMAT=REDUNDANT +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +--echo +--echo ################################## +--echo # Check row_format on ALTER ALGORITHM=INPLACE +SET GLOBAL innodb_default_row_format=COMPACT; + +eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); + +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; + +SET GLOBAL innodb_default_row_format=DYNAMIC; +ALTER TABLE t1 DROP INDEX k1; + +--echo # Because it is in-place operation, there is no rebuild, so the +--echo # original format has to be retained. +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +SET GLOBAL innodb_default_row_format = @row_format; diff --git a/mysql-test/suite/innodb/t/default_row_format_compatibility.test b/mysql-test/suite/innodb/t/default_row_format_compatibility.test new file mode 100644 index 0000000000000000000000000000000000000000..0f433b1fcfe2bdb150772b14e331f8d167f151be --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_compatibility.test @@ -0,0 +1,174 @@ +--source include/have_innodb.inc + +SET @row_format = @@GLOBAL.innodb_default_row_format; +SET @large_prefix = @@GLOBAL.innodb_large_prefix; +SET @file_format = @@GLOBAL.innodb_file_format; +SET GLOBAL innodb_file_format = barracuda; + +# set the variables +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +--echo # ########################################################### +--echo # Check with Import/Export tablespace with Default_row_format + +# Set row_format=Compact +SET GLOBAL innodb_default_row_format=Compact; + +# Check row_format=Compact +SELECT @@innodb_default_row_format; + +# Check file_per_table=1 +SELECT @@innodb_file_per_table; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab VALUES(1); +INSERT INTO tab VALUES(2); + +# Check the rows +SELECT * FROM tab; + +FLUSH TABLE tab FOR EXPORT; + +# Take the backup of the ibd and cfg files +--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg +--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd + +UNLOCK TABLES; + +# Cleanup +DROP TABLE tab; + +# Set the default_row_format=Dynamic +SET GLOBAL innodb_default_row_format=Dynamic; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; + +# Remove the *.ibd file +ALTER TABLE tab DISCARD TABLESPACE; + +# Move the *.ibd,*.cfg file into orginal location +--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg +--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd + +--error ER_TABLE_SCHEMA_MISMATCH +ALTER TABLE tab IMPORT TABLESPACE; + +# Take the backup of the ibd and cfg files +--copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg +--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd + +# Cleanup +DROP TABLE tab; + +# Remove orphan files +--remove_file $MYSQLD_DATADIR/test/tab.cfg +--remove_file $MYSQLD_DATADIR/test/tab.ibd + +# Set the default_row_format=Compact +SET GLOBAL innodb_default_row_format=Compact; + +# Check row_format=Compact +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Remove the *.ibd file +ALTER TABLE tab DISCARD TABLESPACE; + +# Move the *ibd,*.cfg file into orginal location +--copy_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.ibd +--move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg + +call mtr.add_suppression("InnoDB: Tried to read .* bytes at offset 0"); + +--error ER_INTERNAL_ERROR +ALTER TABLE tab IMPORT TABLESPACE; +--remove_file $MYSQLD_DATADIR/test/tab.ibd +--move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd + +# Check import is successful (because same row_format) +ALTER TABLE tab IMPORT TABLESPACE; + +# Check the rows +SELECT * FROM tab; + +# Cleanup +DROP TABLE tab; + +--echo # ########################################################### +# Check when Index Column size (3070 bytes) is too long, Change row_format +# Check when Index Column size (767 bytes), Change row_format +# Dynamic to Compact to Dynamic + +# Set the default_row_format=Dynamic +SET GLOBAL innodb_default_row_format=Dynamic; +SET GLOBAL innodb_large_prefix=ON; + +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(3070))) ENGINE= InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Change row_format to Compact +SET GLOBAL innodb_default_row_format=COMPACT; + +# Check error ERROR 1709 (HY000): Index column size too large +-- error ER_INDEX_COLUMN_TOO_LONG +ALTER TABLE tab ROW_FORMAT=COMPACT; + +# Cleanup +DROP TABLE tab; + +# Change the default_row_format to default +SET GLOBAL innodb_default_row_format=Default; +SELECT @@innodb_default_row_format; +SET GLOBAL innodb_default_row_format=Dynamic; + +# Change row_format to Dynamic +SELECT @@innodb_default_row_format; + +CREATE TABLE tab(a INT PRIMARY KEY, b VARCHAR(5000), KEY idx1(b(767))) ENGINE= InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +INSERT INTO tab(a,b) VALUES(1,'Check with max column size'); + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors because Compact allows 767 bytes +ALTER TABLE tab ROW_FORMAT=COMPACT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors +ALTER TABLE tab ROW_FORMAT=COMPRESSED; + +# Check by SELECT, no errors +SELECT * FROM tab; + +# Check no errors +ALTER TABLE tab ROW_FORMAT=Dynamic; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 'tab'; + +# Cleanup +DROP TABLE tab; + +SET GLOBAL innodb_default_row_format = @row_format; +SET GLOBAL innodb_large_prefix = @large_prefix; +SET GLOBAL innodb_file_format = @file_format; diff --git a/mysql-test/suite/innodb/t/default_row_format_create.test b/mysql-test/suite/innodb/t/default_row_format_create.test new file mode 100644 index 0000000000000000000000000000000000000000..e0981abf7ebdaed21b134c1e40759fb9d386b244 --- /dev/null +++ b/mysql-test/suite/innodb/t/default_row_format_create.test @@ -0,0 +1,28 @@ +--source include/have_innodb.inc +--source include/innodb_row_format.inc + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=COMPACT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT,c2 BLOB) ENGINE=InnoDB +ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # +SHOW TABLE STATUS LIKE 't1'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/file_format_defaults-master.opt b/mysql-test/suite/innodb/t/file_format_defaults-master.opt new file mode 100644 index 0000000000000000000000000000000000000000..202ecee6d48bcb3b569b3a719acaf1e017fdd1a1 --- /dev/null +++ b/mysql-test/suite/innodb/t/file_format_defaults-master.opt @@ -0,0 +1 @@ +--innodb_large_prefix=OFF --innodb_file_format=barracuda --innodb-file-format-check=off --innodb-file-format-max=antelope diff --git a/mysql-test/suite/innodb/t/file_format_defaults.test b/mysql-test/suite/innodb/t/file_format_defaults.test new file mode 100644 index 0000000000000000000000000000000000000000..c16ca068e467de8d17d3942e08e28b1449f38796 --- /dev/null +++ b/mysql-test/suite/innodb/t/file_format_defaults.test @@ -0,0 +1,73 @@ +#*********************************************************** +# WL#7703: +# Check the max key length 3072 when innodb_large_prefix=ON +# Check boundary value of max key length 3073 +# When innodb_file_format=Antelope, compress DDLs fails +# Check file_format_max becomes Barracuda on DDL operation +# on compression table. +#*********************************************************** +-- source include/have_innodb.inc +-- source include/have_innodb_16k.inc + +# Check some default settings +SELECT @@innodb_strict_mode; + +SELECT @@innodb_file_per_table; + +SET @file_format = @@GLOBAL.innodb_file_format; + +SET GLOBAL innodb_large_prefix=ON; +SET SQL_MODE=strict_all_tables; + +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +SHOW CREATE TABLE tab0; +DROP TABLE tab0; + +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE tab0 (c1 VARCHAR(65530), KEY(c1(3073))) ENGINE=InnoDB KEY_BLOCK_SIZE=2; + +SET GLOBAL innodb_file_format=Antelope; + +# WL#8307 Make ROW_FORMAT=DYNAMIC the default +# will allow ROW_FORMAT=DYNAMIC even if innodb_file_format=Antelope. +CREATE TABLE tab0(c1 INT,c2 LONGBLOB ) ENGINE=InnoDB ROW_FORMAT=Dynamic; +DROP TABLE tab0; + +SET GLOBAL innodb_file_format=Default; + +SELECT @@innodb_file_format; + +SET GLOBAL innodb_strict_mode=OFF; + +# Check with default value +SET GLOBAL innodb_strict_mode=Default; + +SELECT @@innodb_strict_mode; + +SET GLOBAL innodb_large_prefix=OFF; + +SELECT @@innodb_large_prefix; + +SET GLOBAL innodb_large_prefix=Default; + +# Check with default value +SELECT @@innodb_large_prefix; + +SET GLOBAL innodb_file_format_max=Default; + +# Check with default value +SELECT @@innodb_file_format_max; + +CREATE TABLE tab1(c1 int ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; + +# Check file format changed to Barracuda, on DDL operation +SELECT @@innodb_file_format_max; + +SET GLOBAL innodb_file_format_max=Default; + +# Restore to the value that we explicitly used at startup. +SET GLOBAL innodb_large_prefix=off; + +SET GLOBAL innodb_file_format = @file_format; + +DROP TABLE tab1; diff --git a/mysql-test/suite/innodb/t/innodb-alter-nullable.test b/mysql-test/suite/innodb/t/innodb-alter-nullable.test index bb5cdee000ad1d5ec70688004fe6a9856f20cec6..d039459f91f0d195a3b07a2a707b48717ba5bcbd 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-nullable.test +++ b/mysql-test/suite/innodb/t/innodb-alter-nullable.test @@ -71,6 +71,11 @@ WHERE NAME='test/t'; DROP TABLE t; +CREATE TABLE t1(c1 INT) ENGINE=InnoDB; +ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1); +ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1); +DROP TABLE t1; + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index af75482703cf610ab02e039f82112ac349ed1605..0d3cc6f1733690eb824a86899e95d7765f8f1b23 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -481,3 +481,24 @@ eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace; eval DROP TABLE $source_db.t1; eval DROP DATABASE $source_db; eval DROP DATABASE $dest_db; + +--echo # +--echo # BUG #26334149 MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES ARE +--echo # ORPHANED DUE TO RENAME TABLE +--echo # +CREATE DATABASE db1; USE db1; +CREATE TABLE notes ( + id int(11) NOT NULL AUTO_INCREMENT, + body text COLLATE utf8_unicode_ci, + PRIMARY KEY (id) + ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci +ROW_FORMAT=COMPRESSED; + +ALTER TABLE notes ADD FULLTEXT INDEX index_ft_body (body(255)); +DROP INDEX index_ft_body ON notes; + +CREATE DATABASE db2; +RENAME TABLE db1.notes TO db2.notes; +DROP DATABASE db1; +DROP DATABASE db2; diff --git a/mysql-test/suite/innodb/t/innodb-blob.test b/mysql-test/suite/innodb/t/innodb-blob.test index 775d52c9ce84a134334394706e3dd27a03ef3e8b..17fd194dbebfac70dd26c2fa528c6492509bacbe 100644 --- a/mysql-test/suite/innodb/t/innodb-blob.test +++ b/mysql-test/suite/innodb/t/innodb-blob.test @@ -5,12 +5,14 @@ --source include/have_innodb.inc --source include/have_innodb_16k.inc -# DEBUG_SYNC must be compiled in. +--source include/have_debug.inc --source include/have_debug_sync.inc # Embedded server does not support restarting --source include/not_embedded.inc +FLUSH TABLES; + CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/innodb-mdev7046.test b/mysql-test/suite/innodb/t/innodb-mdev7046.test index b4085228e0208f6052618e80a2d9634924ab7fe6..85a257a173912f80e5eecadf66baeb2361d0d7b1 100644 --- a/mysql-test/suite/innodb/t/innodb-mdev7046.test +++ b/mysql-test/suite/innodb/t/innodb-mdev7046.test @@ -9,9 +9,10 @@ # Ignore OS errors -call mtr.add_suppression("InnoDB: File ./test/t1*"); -call mtr.add_suppression("InnoDB: Error number*"); -call mtr.add_suppression("InnoDB: File ./test/t1#p#p1#sp#p1sp0.ibd: 'rename' returned OS error*"); +call mtr.add_suppression("InnoDB: File ./test/t1"); +call mtr.add_suppression("InnoDB: Error number"); +call mtr.add_suppression("InnoDB: Cannot rename file '.*/test/t1#[Pp]#p1#[Ss][Pp]#p1sp0\\.ibd' to"); +call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation."); # MDEV-7046: MySQL#74480 - Failing assertion: os_file_status(newpath, &exists, &type) # after Operating system error number 36 in a file operation diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_default.test b/mysql-test/suite/innodb/t/innodb-page_compression_default.test index 1cc6c917548bf8cc981165885c781aaf19abce43..34b1829485e7e92e0fd8832764d1d74cbeeed063 100644 --- a/mysql-test/suite/innodb/t/innodb-page_compression_default.test +++ b/mysql-test/suite/innodb/t/innodb-page_compression_default.test @@ -1,8 +1,6 @@ --source include/have_innodb.inc --source include/not_embedded.inc -call mtr.add_suppression("InnoDB: Compression failed for space [0-9]+ name test/innodb_page_compressed[0-9] len [0-9]+ err 2 write_size [0-9]+."); - # All page compression test use the same --source include/innodb-page-compression.inc diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test b/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test index 532ec294d28d5d150c21cab5b3facbb21a45cacd..0186c24ef2e38672e18109d9d5951854d2c56d09 100644 --- a/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test +++ b/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test @@ -2,8 +2,6 @@ -- source include/have_innodb_snappy.inc --source include/not_embedded.inc -call mtr.add_suppression("InnoDB: Compression failed for space [0-9]+ name test/innodb_page_compressed[0-9] len [0-9]+ err 2 write_size [0-9]+."); - # snappy set global innodb_compression_algorithm = snappy; diff --git a/mysql-test/suite/innodb/t/innodb_bug54044.test b/mysql-test/suite/innodb/t/innodb_bug54044.test index 61a09375ae174e1eaa123369e9ada87b684a089d..cfc6f3c3f0a9bd8259c947a575222e920328253e 100644 --- a/mysql-test/suite/innodb/t/innodb_bug54044.test +++ b/mysql-test/suite/innodb/t/innodb_bug54044.test @@ -16,13 +16,3 @@ CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL), GREATEST(NULL, NULL), NULL; SHOW CREATE TABLE tmp; DROP TABLE tmp; - -# These 'create table' operations should fail because of -# using NULL datatype - -CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB; -INSERT INTO t1 VALUES ('foo'),('bar'); -FLUSH TABLES; ---error 1005 -CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT VALUES(a) FROM t1; -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_defragment_small.test b/mysql-test/suite/innodb/t/innodb_defragment_small.test index 454333d698608bb0649a7740feed9935cab563b1..c52a58fc5a7c120ffd9173c6709c063d2f3eebb6 100644 --- a/mysql-test/suite/innodb/t/innodb_defragment_small.test +++ b/mysql-test/suite/innodb/t/innodb_defragment_small.test @@ -1,10 +1,17 @@ --source include/have_innodb.inc SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment; +SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only; SET GLOBAL innodb_defragment = 1; +SET GLOBAL innodb_optimize_fulltext_only = 0; -# Small tests copied from innodb.innodb_defragment -CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB; +--echo # +--echo # MDEV-12198 innodb_defragment=1 crashes server on +--echo # OPTIMIZE TABLE when FULLTEXT index exists +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), + KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB; OPTIMIZE TABLE t1; INSERT INTO t1 VALUES (100000, REPEAT('A', 256)); @@ -13,16 +20,18 @@ INSERT INTO t1 VALUES (300000, REPEAT('A', 256)); INSERT INTO t1 VALUES (400000, REPEAT('A', 256)); OPTIMIZE TABLE t1; -DROP TABLE t1; --echo # ---echo # MDEV-12198 innodb_defragment=1 crashes server on ---echo # OPTIMIZE TABLE when FULLTEXT index exists +--echo # MDEV-15824 innodb_defragment=ON trumps +--echo # innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE --echo # -CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB; - +SET GLOBAL innodb_optimize_fulltext_only = 1; OPTIMIZE TABLE t1; +SET GLOBAL innodb_defragment = 0; +OPTIMIZE TABLE t1; + DROP TABLE t1; SET GLOBAL innodb_defragment = @innodb_defragment_orig; +SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig; diff --git a/mysql-test/suite/innodb/t/lock_deleted.test b/mysql-test/suite/innodb/t/lock_deleted.test new file mode 100644 index 0000000000000000000000000000000000000000..8dbad90d3541cea8c7d4f2757685880bd7cc5964 --- /dev/null +++ b/mysql-test/suite/innodb/t/lock_deleted.test @@ -0,0 +1,72 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +--source include/count_sessions.inc + +connect(stop_purge, localhost, root,,); +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connect(delete, localhost, root,,); +connection default; + +CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1,1); +DELETE FROM t1; + +let $i=2; +while ($i) { +let $iso= `SELECT CASE $i WHEN 1 THEN 'UNCOMMITTED' ELSE 'COMMITTED' END`; + +SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked'; +BEGIN; +send INSERT INTO t1 VALUES(1,1); + +connection delete; +SET DEBUG_SYNC='now WAIT_FOR inserted'; +SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked'; +eval SET SESSION TRANSACTION ISOLATION LEVEL READ $iso; +BEGIN; +send DELETE FROM t1 WHERE b=1; + +connection default; +reap; +connection delete; +reap; +COMMIT; + +connection default; +SET DEBUG_SYNC='RESET'; +ROLLBACK; + +dec $i; +} + +SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked'; +BEGIN; +SET innodb_lock_wait_timeout=1; +send INSERT INTO t1 VALUES(1,1); + +connection delete; +SET DEBUG_SYNC='now WAIT_FOR inserted'; +SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked'; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +send DELETE FROM t1 WHERE b=1; + +connection default; +--error ER_LOCK_WAIT_TIMEOUT +reap; +COMMIT; +SET DEBUG_SYNC='RESET'; + +connection delete; +reap; +COMMIT; + +disconnect delete; +disconnect stop_purge; + +connection default; +DROP TABLE t1; + +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/log_file_size.test b/mysql-test/suite/innodb/t/log_file_size.test index 9cc7742f6a8a4db0ebab961b5a2a7813b7e29d29..061bf35ccef71f93e16e847dc4c95ec2495336df 100644 --- a/mysql-test/suite/innodb/t/log_file_size.test +++ b/mysql-test/suite/innodb/t/log_file_size.test @@ -26,7 +26,8 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("InnoDB: innodb_read_only prevents crash recovery"); call mtr.add_suppression("InnoDB: Are you sure you are using the right ib_logfiles"); -call mtr.add_suppression("InnoDB: Cannot create log files in read-only mode"); +call mtr.add_suppression("InnoDB: Cannot (create|resize) log files in read-only mode"); +call mtr.add_suppression("InnoDB: Can't initiate database recovery, running in read-only-mode"); call mtr.add_suppression("InnoDB: Only one log file found"); call mtr.add_suppression("InnoDB: Log file .*ib_logfile[01].* size"); call mtr.add_suppression("InnoDB: Unable to open .*ib_logfile0. to check native AIO read support"); diff --git a/mysql-test/suite/innodb/t/mvcc.test b/mysql-test/suite/innodb/t/mvcc.test new file mode 100644 index 0000000000000000000000000000000000000000..bf76a5de7980662a92efbedb392c32a32fd21805 --- /dev/null +++ b/mysql-test/suite/innodb/t/mvcc.test @@ -0,0 +1,52 @@ +--source include/have_innodb.inc + +SET @save_per_table= @@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table= 1; + +let MYSQLD_DATADIR =`SELECT @@datadir`; + +--echo # +--echo # MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +FLUSH TABLES t1 WITH READ LOCK; +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_backup_tablespace("test", "t1"); +EOF +UNLOCK TABLES; + +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connect (con1,localhost,root,,); +ALTER TABLE t1 FORCE, ALGORITHM=COPY; + +connection default; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t1; +COMMIT; +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connection con1; + +ALTER TABLE t1 DISCARD TABLESPACE; + +perl; +do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; +ib_restore_tablespace("test", "t1"); +EOF + +ALTER TABLE t1 IMPORT TABLESPACE; +disconnect con1; + +connection default; +--echo # FIXME: Block this with ER_TABLE_DEF_CHANGED +SELECT * FROM t1; +COMMIT; +SELECT * FROM t1; + +DROP TABLE t1; + +SET GLOBAL innodb_file_per_table= @save_per_table; diff --git a/mysql-test/suite/innodb/t/read_only_recover_committed.test b/mysql-test/suite/innodb/t/read_only_recover_committed.test new file mode 100644 index 0000000000000000000000000000000000000000..402cbeba1b97e9e51020cbdfa23d4dc71746c0fc --- /dev/null +++ b/mysql-test/suite/innodb/t/read_only_recover_committed.test @@ -0,0 +1,68 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +# need to restart server +--source include/not_embedded.inc + +--connect(con1, localhost, root) +CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t VALUES(1); +BEGIN; +# Generate insert_undo log. +INSERT INTO t VALUES(2); +# Generate update_undo log. +DELETE FROM t WHERE a=2; +--connect(con2, localhost, root) +--echo # Normal MariaDB shutdown would roll back the above transaction. +--echo # We want the transaction to remain open, so we will kill the server +--echo # after ensuring that any non-transactional files are clean. +FLUSH TABLES; +--echo # Create another transaction that will be recovered as COMMITTED. +BEGIN; +# Generate multiple pages of both insert_undo and update_undo, so that +# the state TRX_UNDO_CACHE will not be chosen. +--disable_query_log +let $n= 10000; +while ($n) { +dec $n; +eval INSERT INTO t VALUES(-$n); +eval DELETE FROM t WHERE a=-$n; +} +--enable_query_log +SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL committed WAIT_FOR ever'; +send COMMIT; + +connection default; +SET DEBUG_SYNC='now WAIT_FOR committed'; +--echo # Ensure that the above incomplete transactions become durable. +SET GLOBAL innodb_flush_log_at_trx_commit=1; +BEGIN; +INSERT INTO t VALUES(-10000); +ROLLBACK; +--let $restart_parameters= --innodb-force-recovery=3 +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc +--let $shutdown_timeout= 30 +--disconnect con1 +--disconnect con2 +SELECT * FROM t; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +# refused on MySQL 5.6, MariaDB 10.0, 10.1, but not MariaDB 10.2+ +--error ER_OPEN_AS_READONLY +UPDATE t SET a=3 WHERE a=1; +--let $restart_parameters= --innodb-read-only +--source include/restart_mysqld.inc +--echo # Starting with MariaDB 10.2, innodb_read_only implies READ UNCOMMITTED. +--echo # In earlier versions, this would return the last committed version +--echo # (empty table)! +SELECT * FROM t; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t; +--let $restart_parameters= +--source include/restart_mysqld.inc +SELECT * FROM t; +DROP TABLE t; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; +--let SEARCH_PATTERN= Rolled back recovered transaction [^0] +--source include/search_pattern_in_file.inc diff --git a/mysql-test/suite/innodb/t/recovery_shutdown.test b/mysql-test/suite/innodb/t/recovery_shutdown.test index 28b80cd3818d05bd8a81a3d58b2a9bfd5d3acb8b..42d98ca34c705ca1ec96449442c5bf06ae18b965 100644 --- a/mysql-test/suite/innodb/t/recovery_shutdown.test +++ b/mysql-test/suite/innodb/t/recovery_shutdown.test @@ -41,7 +41,11 @@ INSERT INTO t1(a) SELECT NULL FROM t1; SET GLOBAL innodb_flush_log_at_trx_commit=1; CREATE TABLE u(a SERIAL) ENGINE=INNODB; ---source include/kill_and_restart_mysqld.inc +FLUSH TABLES; + +--let $shutdown_timeout=0 +--source include/restart_mysqld.inc +--let $shutdown_timeout=60 --source include/restart_mysqld.inc --disable_query_log diff --git a/mysql-test/suite/innodb/t/rename_table.test b/mysql-test/suite/innodb/t/rename_table.test new file mode 100644 index 0000000000000000000000000000000000000000..695c0915d147e375e2ca3eed1474fee60ca30475 --- /dev/null +++ b/mysql-test/suite/innodb/t/rename_table.test @@ -0,0 +1,11 @@ +--source include/have_innodb.inc + +call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)"); + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +--replace_regex /\'.*t1\' to/'**path-to-t1**' to/ /to \'.*non.*t1\'/to '**path-to-non-existing-db-t1**'/ +--error ER_ERROR_ON_RENAME +RENAME TABLE t1 TO non_existing_db.t1; + +# Cleanup +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/restart.test b/mysql-test/suite/innodb/t/restart.test new file mode 100644 index 0000000000000000000000000000000000000000..242a03400ff8963674c8226ba0f90cd8672bbc24 --- /dev/null +++ b/mysql-test/suite/innodb/t/restart.test @@ -0,0 +1,78 @@ +--source include/innodb_page_size.inc +--source include/not_embedded.inc + +let datadir= `select @@datadir`; +let page_size= `select @@innodb_page_size`; + +SET GLOBAL innodb_file_format=Barracuda; +SET GLOBAL innodb_file_per_table=1; + +--echo # +--echo # MDEV-15333 MariaDB (still) slow start +--echo # + +# Ensure that on normal startup, no data files are read. +# Note: just like in MySQL, all .ibd files will still be +# opened at least once. + +--echo # FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files +--echo # of tables with .isl file or DATA DIRECTORY attribute. +call mtr.add_suppression("\\[ERROR\\] InnoDB: Invalid flags 0x7a207879 in tablespace 2048948345"); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Error invalid tablespace flags in file '.*td\\.ibd'"); + +CREATE TABLE tr(a INT)ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT +PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC +STATS_PERSISTENT=0 DATA DIRECTORY='$MYSQL_TMP_DIR'; + +--source include/shutdown_mysqld.inc + +--move_file $datadir/test/tr.ibd $datadir/test/tr0.ibd +--move_file $datadir/test/tc.ibd $datadir/test/tc0.ibd +--move_file $MYSQL_TMP_DIR/test/td.ibd $datadir/test/td0.ibd +# TODO: test that MariaDB does not even attempt to open the files +#--mkdir $datadir/test/tr.ibd +#--mkdir $datadir/test/tc.ibd +#--mkdir $MYSQL_TMP_DIR/test/td.ibd + +perl; +die unless open OUT, ">", "$ENV{datadir}/test/tr.ibd"; +print OUT "foo " x $ENV{page_size}; +close OUT or die; +die unless open OUT, ">", "$ENV{datadir}/test/tc.ibd"; +print OUT "bar " x $ENV{page_size}; +close OUT or die; +die unless open OUT, ">", "$ENV{MYSQL_TMP_DIR}/test/td.ibd"; +print OUT "xyz " x $ENV{page_size}; +close OUT or die; +EOF + +--let $restart_parameters= --skip-innodb-buffer-pool-load-at-startup +--source include/start_mysqld.inc +--let $restart_parameters= + +SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); + +--source include/shutdown_mysqld.inc + +# TODO: test that MariaDB does not even attempt to open the files +#--rmdir $datadir/test/tr.ibd +#--rmdir $datadir/test/tc.ibd +#--rmdir $MYSQL_TMP_DIR/test/td.ibd +--remove_file $datadir/test/tr.ibd +--remove_file $datadir/test/tc.ibd +--remove_file $MYSQL_TMP_DIR/test/td.ibd + +--move_file $datadir/test/tr0.ibd $datadir/test/tr.ibd +--move_file $datadir/test/tc0.ibd $datadir/test/tc.ibd +--move_file $datadir/test/td0.ibd $MYSQL_TMP_DIR/test/td.ibd + +--source include/start_mysqld.inc +SELECT * FROM tr; +SELECT * FROM tc; +SELECT * FROM td; +DROP TABLE tr,tc,td; diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-basic.result b/mysql-test/suite/innodb_fts/r/basic.result similarity index 89% rename from mysql-test/suite/innodb_fts/r/innodb-fts-basic.result rename to mysql-test/suite/innodb_fts/r/basic.result index fe767476fe6b4956834a304d075947cb25ce3ad2..ae23b93dc847e138f570cebe423313e5ee13c680 100644 --- a/mysql-test/suite/innodb_fts/r/innodb-fts-basic.result +++ b/mysql-test/suite/innodb_fts/r/basic.result @@ -257,3 +257,37 @@ WHERE MATCH (title,body) AGAINST ('"more test proximity"' IN BOOLEAN MODE); id title body drop table articles; +# +# Bug #22679185 INVALID INNODB FTS DOC ID DURING INSERT +# +create table t1 (f1 int not null primary key, f2 varchar(100), +FTS_DOC_ID bigint(20) unsigned not null, +unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), +fulltext key (f2))engine=innodb; +insert into t1 values(1, "This is the first record", 20000); +insert into t1 values(2, "This is the second record", 40000); +select FTS_DOC_ID from t1; +FTS_DOC_ID +20000 +40000 +drop table t1; +create table t1 (f1 int not null primary key, f2 varchar(100), +FTS_DOC_ID bigint(20) unsigned not null auto_increment, +unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), +fulltext key (f2))engine=innodb; +set auto_increment_increment = 65535; +insert into t1(f1, f2) values(1, "This is the first record"); +insert into t1(f1, f2) values(2, "This is the second record"); +insert into t1(f1, f2) values(3, "This is the third record"); +select FTS_DOC_ID from t1; +FTS_DOC_ID +1 +65536 +131071 +drop table t1; +call mtr.add_suppression("\\[ERROR\\] InnoDB: Doc ID 20030101000000 is too big. Its difference with largest used Doc ID 0 cannot exceed or equal to 65535"); +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), FULLTEXT(title)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, NULL), (20030101000000, 20030102000000); +ERROR HY000: Invalid InnoDB FTS Doc ID +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-basic.test b/mysql-test/suite/innodb_fts/t/basic.test similarity index 85% rename from mysql-test/suite/innodb_fts/t/innodb-fts-basic.test rename to mysql-test/suite/innodb_fts/t/basic.test index 095713130f10be19cd22d5cd5548b41302296af6..58f36be08a52a61a989c35dc11d6768b72a7b8c5 100644 --- a/mysql-test/suite/innodb_fts/t/innodb-fts-basic.test +++ b/mysql-test/suite/innodb_fts/t/basic.test @@ -2,11 +2,6 @@ -- source include/have_innodb.inc -if (`select plugin_auth_version <= "5.6.10" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in InnoDB 5.6.10 or earlier -} - # Create FTS table CREATE TABLE articles ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -226,3 +221,37 @@ SELECT * FROM articles AGAINST ('"more test proximity"' IN BOOLEAN MODE); drop table articles; + +--echo # +--echo # Bug #22679185 INVALID INNODB FTS DOC ID DURING INSERT +--echo # + +create table t1 (f1 int not null primary key, f2 varchar(100), + FTS_DOC_ID bigint(20) unsigned not null, + unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), + fulltext key (f2))engine=innodb; + +insert into t1 values(1, "This is the first record", 20000); +insert into t1 values(2, "This is the second record", 40000); +select FTS_DOC_ID from t1; +drop table t1; + + +create table t1 (f1 int not null primary key, f2 varchar(100), + FTS_DOC_ID bigint(20) unsigned not null auto_increment, + unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), + fulltext key (f2))engine=innodb; + +set auto_increment_increment = 65535; +insert into t1(f1, f2) values(1, "This is the first record"); +insert into t1(f1, f2) values(2, "This is the second record"); +insert into t1(f1, f2) values(3, "This is the third record"); +select FTS_DOC_ID from t1; +drop table t1; + +call mtr.add_suppression("\\[ERROR\\] InnoDB: Doc ID 20030101000000 is too big. Its difference with largest used Doc ID 0 cannot exceed or equal to 65535"); +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), FULLTEXT(title)) ENGINE=InnoDB; +--error 182 +INSERT INTO t1 VALUES (NULL, NULL), (20030101000000, 20030102000000); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_zip/r/innodb-create-options.result b/mysql-test/suite/innodb_zip/r/innodb-create-options.result index fe3d799229d5de7af4dc5e9502a99efa511e945a..e961d0ca7d097e4193df18877c11f937d3dfff2a 100644 --- a/mysql-test/suite/innodb_zip/r/innodb-create-options.result +++ b/mysql-test/suite/innodb_zip/r/innodb-create-options.result @@ -282,12 +282,12 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelop Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; -ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; Level Code Message @@ -318,13 +318,10 @@ Level Code Message Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope. Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' ALTER TABLE t1 ROW_FORMAT=DYNAMIC; -ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SET GLOBAL innodb_file_format=Barracuda; -DROP TABLE IF EXISTS t1; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; @@ -369,12 +366,12 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; -ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; Level Code Message @@ -405,11 +402,11 @@ Level Code Message Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' ALTER TABLE t1 ROW_FORMAT=DYNAMIC; -ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1478 Table storage engine 'InnoDB' does not support the create option 'ROW_FORMAT' +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +t1 Dynamic row_format=DYNAMIC ALTER TABLE t1 ROW_FORMAT=COMPACT; SHOW WARNINGS; Level Code Message @@ -789,16 +786,11 @@ TABLE_NAME ROW_FORMAT CREATE_OPTIONS t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. SHOW WARNINGS; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; TABLE_NAME ROW_FORMAT CREATE_OPTIONS -t1 Compact row_format=DYNAMIC +t1 Dynamic row_format=DYNAMIC SET GLOBAL innodb_file_format=Barracuda; ALTER TABLE t1 ADD COLUMN f2 INT; SHOW WARNINGS; diff --git a/mysql-test/suite/innodb_zip/r/innodb-zip.result b/mysql-test/suite/innodb_zip/r/innodb-zip.result index 584a8a5d647001bcaf2069f32da2b5ab78cf2a8b..2695df641876c0d819c45ddc4caaf8ed87730920 100644 --- a/mysql-test/suite/innodb_zip/r/innodb-zip.result +++ b/mysql-test/suite/innodb_zip/r/innodb-zip.result @@ -22,9 +22,6 @@ Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=4. Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. create table t1(a int primary key) engine=innodb row_format=dynamic; -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. create table t2(a int primary key) engine=innodb row_format=redundant; create table t3(a int primary key) engine=innodb row_format=compact; create table t4(a int primary key) engine=innodb key_block_size=9; @@ -75,7 +72,7 @@ SELECT table_schema, table_name, row_format, data_length, index_length FROM info table_schema table_name row_format data_length index_length mysqltest_innodb_zip t0 Compact {valid} 0 mysqltest_innodb_zip t00 Compact {valid} 0 -mysqltest_innodb_zip t1 Compact {valid} 0 +mysqltest_innodb_zip t1 Dynamic {valid} 0 mysqltest_innodb_zip t10 Dynamic {valid} 0 mysqltest_innodb_zip t11 Compressed 1024 0 mysqltest_innodb_zip t12 Compressed 1024 0 @@ -295,19 +292,16 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. Error 1005 Can't create table `mysqltest_innodb_zip`.`t6` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t7 (id int primary key) engine = innodb row_format = dynamic; -ERROR HY000: Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") show warnings; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. -Error 1005 Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql'; table_schema table_name row_format data_length index_length +mysqltest_innodb_zip t7 Dynamic {valid} 0 mysqltest_innodb_zip t8 Compact {valid} 0 mysqltest_innodb_zip t9 Redundant {valid} 0 -drop table t8, t9; +drop table t7, t8, t9; set global innodb_file_per_table = on; set global innodb_file_format = `0`; create table t1 (id int primary key) engine = innodb key_block_size = 1; @@ -339,19 +333,16 @@ Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelop Error 1005 Can't create table `mysqltest_innodb_zip`.`t6` (errno: 140 "Wrong create options") Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t7 (id int primary key) engine = innodb row_format = dynamic; -ERROR HY000: Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") show warnings; Level Code Message -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Error 1005 Can't create table `mysqltest_innodb_zip`.`t7` (errno: 140 "Wrong create options") -Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb' AND table_schema != 'mysql'; table_schema table_name row_format data_length index_length +mysqltest_innodb_zip t7 Dynamic {valid} 0 mysqltest_innodb_zip t8 Compact {valid} 0 mysqltest_innodb_zip t9 Redundant {valid} 0 -drop table t8, t9; +drop table t7, t8, t9; set global innodb_file_per_table=1; set global innodb_file_format=Antelope; set global innodb_file_per_table=on; diff --git a/mysql-test/suite/innodb_zip/t/innodb-create-options.test b/mysql-test/suite/innodb_zip/t/innodb-create-options.test index 53d739feccbb847be255b394704d07dcd18c1c3d..282b588c841d0c0ddf76fe524c51b9134996f48e 100644 --- a/mysql-test/suite/innodb_zip/t/innodb-create-options.test +++ b/mysql-test/suite/innodb_zip/t/innodb-create-options.test @@ -244,10 +244,10 @@ CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; --replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; --replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; ---replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; @@ -264,11 +264,10 @@ SHOW WARNINGS; --error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=COMPRESSED; SHOW WARNINGS; ---error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=DYNAMIC; SHOW WARNINGS; SET GLOBAL innodb_file_format=Barracuda; -DROP TABLE IF EXISTS t1; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; SET GLOBAL innodb_file_format=Antelope; ALTER TABLE t1 ADD COLUMN f1 INT; @@ -296,11 +295,10 @@ SHOW WARNINGS; CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED; --replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; ---replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE CREATE TABLE t1 ( i INT ) ROW_FORMAT=DYNAMIC; ---replace_regex / - .*[0-9]*[)]/)/ SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; +DROP TABLE t1; CREATE TABLE t1 ( i INT ) ROW_FORMAT=REDUNDANT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; @@ -317,9 +315,9 @@ SHOW WARNINGS; --error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=COMPRESSED; SHOW WARNINGS; ---error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ROW_FORMAT=DYNAMIC; SHOW WARNINGS; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; ALTER TABLE t1 ROW_FORMAT=COMPACT; SHOW WARNINGS; SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables WHERE TABLE_NAME = 't1'; diff --git a/mysql-test/suite/innodb_zip/t/innodb-zip.test b/mysql-test/suite/innodb_zip/t/innodb-zip.test index e8ba98f14ce724d6456cb5de136510bb5f35fe1e..e9bac78f99edb449aaf354cb9734224ef5df98d0 100644 --- a/mysql-test/suite/innodb_zip/t/innodb-zip.test +++ b/mysql-test/suite/innodb_zip/t/innodb-zip.test @@ -275,16 +275,14 @@ create table t6 (id int primary key) engine = innodb row_format = compressed; --replace_regex / - .*[0-9]*[)]/)/ show warnings; --replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE create table t7 (id int primary key) engine = innodb row_format = dynamic; ---replace_regex / - .*[0-9]*[)]/)/ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; --replace_result 16384 {valid} 8192 {valid} 4096 {valid} --eval $query_i_s -drop table t8, t9; +drop table t7, t8, t9; #test valid values with innodb_file_format unset set global innodb_file_per_table = on; @@ -312,17 +310,14 @@ show warnings; create table t6 (id int primary key) engine = innodb row_format = compressed; --replace_regex / - .*[0-9]*[)]/)/ show warnings; ---replace_regex / - .*[0-9]*[)]/)/ ---error ER_CANT_CREATE_TABLE create table t7 (id int primary key) engine = innodb row_format = dynamic; ---replace_regex / - .*[0-9]*[)]/)/ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; --replace_result 16384 {valid} 8192 {valid} 4096 {valid} --eval $query_i_s -drop table t8, t9; +drop table t7, t8, t9; eval set global innodb_file_per_table=$per_table; eval set global innodb_file_format=$format; diff --git a/mysql-test/suite/maria/alter.result b/mysql-test/suite/maria/alter.result index 1a7daf5a1ee148804924ccb02f598b0e6fe3d0b9..c63688dddd646e950dc80ebeb4de35dba78bd1a2 100644 --- a/mysql-test/suite/maria/alter.result +++ b/mysql-test/suite/maria/alter.result @@ -31,3 +31,19 @@ pk i 8 88 9 99 DROP TABLE t1; +CREATE TABLE t1 (f INT) ENGINE=Aria transactional=1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1 +INSERT INTO t1 VALUES (1),(2); +ALTER TABLE t1 ORDER BY unknown_column; +ERROR 42S22: Unknown column 'unknown_column' in 'order clause' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1 +CREATE TABLE t2 SELECT * FROM t1; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/maria/alter.test b/mysql-test/suite/maria/alter.test index abca48656887d4e8afa77517ed7de504705e0b37..09672cdfa3b2f857fecf6bec015ad298499ce404 100644 --- a/mysql-test/suite/maria/alter.test +++ b/mysql-test/suite/maria/alter.test @@ -25,3 +25,20 @@ INSERT INTO t1 VALUES (2,0),(3,33),(4,0),(5,55),(6,66),(7,0),(8,88),(9,99); ALTER TABLE t1 ENABLE KEYS; SELECT * FROM t1 WHERE i = 0 OR pk BETWEEN 6 AND 10; DROP TABLE t1; + +# +# MDEV-14943 +# Assertion `block->type == PAGECACHE_EMPTY_PAGE || block->type == type || +# type == PAGECACHE_LSN_PAGE || type == PAGECACHE_READ_UNKNOWN_PAGE || +# block->type == PAGECACHE_READ_UNKNOWN_PAGE' failed in pagecache_read upon +# CREATE ... SELECT from Aria table +# + +CREATE TABLE t1 (f INT) ENGINE=Aria transactional=1; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1),(2); +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1 ORDER BY unknown_column; +SHOW CREATE TABLE t1; +CREATE TABLE t2 SELECT * FROM t1; +DROP TABLE t1, t2; diff --git a/mysql-test/suite/maria/dynamic.result b/mysql-test/suite/maria/dynamic.result new file mode 100644 index 0000000000000000000000000000000000000000..1e87010e9cafaa71595d5705c2c790dcd2edf252 --- /dev/null +++ b/mysql-test/suite/maria/dynamic.result @@ -0,0 +1,4 @@ +create table t1 (a blob, b varchar(20000)) engine=aria row_format=dynamic; +insert t1 (b) values (repeat('a', 20000)); +update t1 set b='b'; +drop table t1; diff --git a/mysql-test/suite/maria/dynamic.test b/mysql-test/suite/maria/dynamic.test new file mode 100644 index 0000000000000000000000000000000000000000..f8a1e98cd41b6e47f9fa7cfa9f71ed72a7be64a0 --- /dev/null +++ b/mysql-test/suite/maria/dynamic.test @@ -0,0 +1,7 @@ +# +# MDEV-13748 Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed in virtual THD::~THD after query with INTERSECT +# +create table t1 (a blob, b varchar(20000)) engine=aria row_format=dynamic; +insert t1 (b) values (repeat('a', 20000)); +update t1 set b='b'; +drop table t1; diff --git a/mysql-test/suite/maria/lock.result b/mysql-test/suite/maria/lock.result index 90250568ef5cbf664608361822fc5dc40446002e..1c9d6b18100c9f69e0c75dd4bb5db21de10e7a75 100644 --- a/mysql-test/suite/maria/lock.result +++ b/mysql-test/suite/maria/lock.result @@ -99,3 +99,13 @@ f2 3 unlock tables; DROP TABLE t1,t2,tmp; +# +# MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt +# +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT, pk INT, PRIMARY KEY (pk)) ENGINE=Aria; +INSERT INTO t1 VALUES ('foo',10,1), ('foo',1,2); +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD UNIQUE KEY (f1); +ERROR 23000: Duplicate entry 'foo' for key 'f1' +ALTER TABLE t1 ADD KEY (f2); +DROP TABLE t1; diff --git a/mysql-test/suite/maria/lock.test b/mysql-test/suite/maria/lock.test index 57447a18c551a8ea65deccc55ffa1aecf90aa4b9..4f3d4e8065ec688e11bd129250ff1209e6d9d936 100644 --- a/mysql-test/suite/maria/lock.test +++ b/mysql-test/suite/maria/lock.test @@ -105,3 +105,15 @@ INSERT INTO t2 (f2) SELECT f3 FROM tmp AS tmp_alias; select * from t2; unlock tables; DROP TABLE t1,t2,tmp; + +--echo # +--echo # MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt +--echo # + +CREATE TABLE t1 (f1 VARCHAR(3), f2 INT, pk INT, PRIMARY KEY (pk)) ENGINE=Aria; +INSERT INTO t1 VALUES ('foo',10,1), ('foo',1,2); +LOCK TABLE t1 WRITE; +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE KEY (f1); +ALTER TABLE t1 ADD KEY (f2); +DROP TABLE t1; diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result index 8078687dad5f2c203302179f466637468d0ef020..f4d7f3d32c6a5257e8b2abfcc74472f584d4a882 100644 --- a/mysql-test/suite/maria/maria.result +++ b/mysql-test/suite/maria/maria.result @@ -2771,3 +2771,11 @@ test.t1 check status OK SET aria_repair_threads=@@global.aria_repair_threads; SET aria_sort_buffer_size=@@global.aria_sort_buffer_size; DROP TABLE t1; +CREATE TABLE t1(a INT, b CHAR(10), KEY(a), KEY(b)); +INSERT INTO t1 VALUES(1,'0'),(2,'0'),(3,'0'),(4,'0'),(5,'0'), +(6,'0'),(7,'0'); +flush tables test.t1 for export; +insert into t1 values (8,'0'); +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +drop table t1; diff --git a/mysql-test/suite/maria/maria.test b/mysql-test/suite/maria/maria.test index 27e9a45fda758897c9573e46ca1e9df34376f30c..17dfb803328bdba95180a86eb98c595b67fcc8b8 100644 --- a/mysql-test/suite/maria/maria.test +++ b/mysql-test/suite/maria/maria.test @@ -2028,6 +2028,19 @@ SET aria_repair_threads=@@global.aria_repair_threads; SET aria_sort_buffer_size=@@global.aria_sort_buffer_size; DROP TABLE t1; +# +# Check FLUSH FOR EXPORT +# + +CREATE TABLE t1(a INT, b CHAR(10), KEY(a), KEY(b)); +INSERT INTO t1 VALUES(1,'0'),(2,'0'),(3,'0'),(4,'0'),(5,'0'), + (6,'0'),(7,'0'); +flush tables test.t1 for export; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +insert into t1 values (8,'0'); +unlock tables; +drop table t1; + # # End of test # diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt new file mode 100644 index 0000000000000000000000000000000000000000..52b6b743ac81073c6c9ef25950f304995f918ed9 --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt @@ -0,0 +1 @@ +--innodb --innodb-data-home-dir= --innodb-data-file-path=$MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1:3M;ibdata_second:1M:autoextend \ No newline at end of file diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.result b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result new file mode 100644 index 0000000000000000000000000000000000000000..fe211e71f2f4a7ac3e2fd3aa57f6d9ac234cb21a --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.result @@ -0,0 +1,10 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +# xtrabackup backup +# remove datadir +# xtrabackup copy back +# restart server +SELECT * from t; +i +1 +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.test b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test new file mode 100644 index 0000000000000000000000000000000000000000..6717f16d1999f701ce411c59e5f7094c941b0689 --- /dev/null +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test @@ -0,0 +1,31 @@ +# This test just backs up and restores empty database +# Innodb system tablespace is specified with absolute path in the .opt file +CREATE TABLE t(i INT) ENGINE INNODB; +INSERT INTO t VALUES(1); +echo # xtrabackup backup; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $_innodb_data_file_path=`select @@innodb_data_file_path`; +let $_innodb_data_home_dir=`select @@innodb_data_home_dir`; +let $_datadir= `SELECT @@datadir`; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; + +--source include/shutdown_mysqld.inc +echo # remove datadir; +rmdir $_datadir; +#remove out-of-datadir ibdata1 +remove_file $MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1; +echo # xtrabackup copy back; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir "--innodb_data_file_path=$_innodb_data_file_path" --innodb_data_home_dir=$_innodb_data_home_dir; +echo # restart server; +--source include/start_mysqld.inc +--enable_result_log + +SELECT * from t; +DROP TABLE t; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/backup_ssl.result b/mysql-test/suite/mariabackup/backup_ssl.result new file mode 100644 index 0000000000000000000000000000000000000000..6e59da6d43a2551be92592b56666d4aac811b6c4 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_ssl.result @@ -0,0 +1,9 @@ +GRANT ALL PRIVILEGES on *.* TO backup_user IDENTIFIED by 'x' REQUIRE SSL; +FLUSH PRIVILEGES; +# xtrabackup backup +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart server +DROP USER backup_user; diff --git a/mysql-test/suite/mariabackup/backup_ssl.test b/mysql-test/suite/mariabackup/backup_ssl.test new file mode 100644 index 0000000000000000000000000000000000000000..e858c834d297cb32da7f322e287da59daefeeee3 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_ssl.test @@ -0,0 +1,16 @@ +GRANT ALL PRIVILEGES on *.* TO backup_user IDENTIFIED by 'x' REQUIRE SSL; +FLUSH PRIVILEGES; +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --user=backup_user --password=x --ssl --backup --target-dir=$targetdir; +--enable_result_log + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log +DROP USER backup_user; +rmdir $targetdir; + diff --git a/mysql-test/suite/mariabackup/undo_space_id.opt b/mysql-test/suite/mariabackup/undo_space_id.opt new file mode 100644 index 0000000000000000000000000000000000000000..01b1d91e820c79c796a2db5bf9d8d7eff469af0b --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.opt @@ -0,0 +1,2 @@ +--debug=d,innodb_undo_upgrade +--innodb_undo_tablespaces=2 diff --git a/mysql-test/suite/mariabackup/undo_space_id.result b/mysql-test/suite/mariabackup/undo_space_id.result new file mode 100644 index 0000000000000000000000000000000000000000..96d3e2a58f4104513672524fdb76a3c79ab33def --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.result @@ -0,0 +1,13 @@ +# Create 2 UNDO TABLESPACE(UNDO003, UNDO004) +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); +# xtrabackup backup +# Display undo log files from target directory +undo003 +undo004 +# xtrabackup prepare +# Display undo log files from targer directory +undo003 +undo004 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/undo_space_id.test b/mysql-test/suite/mariabackup/undo_space_id.test new file mode 100644 index 0000000000000000000000000000000000000000..8adeb18e5a754a973467f2fa5096890e58131a94 --- /dev/null +++ b/mysql-test/suite/mariabackup/undo_space_id.test @@ -0,0 +1,25 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--echo # Create 2 UNDO TABLESPACE(UNDO003, UNDO004) + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(a varchar(60)) ENGINE INNODB; +start transaction; +INSERT INTO t1 VALUES(1); + +--echo # xtrabackup backup +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log +--echo # Display undo log files from target directory +list_files $basedir undo*; + +--echo # xtrabackup prepare +exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir; +--echo # Display undo log files from targer directory +list_files $basedir undo*; + +DROP TABLE t1; +rmdir $basedir; diff --git a/mysql-test/suite/parts/inc/part_alter_values.inc b/mysql-test/suite/parts/inc/part_alter_values.inc index 0d4929d98205df81443b00a74ea2af552d379804..ac69169a9caa6539f93864e101c307ae475b486d 100644 --- a/mysql-test/suite/parts/inc/part_alter_values.inc +++ b/mysql-test/suite/parts/inc/part_alter_values.inc @@ -35,3 +35,13 @@ ALTER TABLE t1 REORGANIZE PARTITION p1 INTO PARTITION p3 VALUES IN (4,5,6) ); DROP TABLE t1; + +# +# MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION +# +--eval create table t1 (i int) engine=$engine partition by range(i) (partition p0 values less than (10)) +lock table t1 write; +--error ER_SAME_NAME_PARTITION +alter table t1 add partition (partition p0 values less than (20)); +alter table t1 add partition (partition p1 values less than (20)) /* comment */; +drop table t1; diff --git a/mysql-test/suite/parts/r/longname.result b/mysql-test/suite/parts/r/longname.result index 6424ba282977aa8b181f5e24455d324f8808da3a..5a223cf65fc638a0bea10cdec60665e025af5645 100644 --- a/mysql-test/suite/parts/r/longname.result +++ b/mysql-test/suite/parts/r/longname.result @@ -12,15 +12,6 @@ SUBPARTITION BY HASH ( id2 ) SUBPARTITIONS 2 ( PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB, PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB); -Warnings: -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. -Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. -Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. select database_name, table_name, length(table_name) from mysql.innodb_table_stats where database_name = 'mysqltest1'; database_name table_name length(table_name) CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé ( diff --git a/mysql-test/suite/parts/r/partition_alter_innodb.result b/mysql-test/suite/parts/r/partition_alter_innodb.result index 29076a3c178217f134a40791a5555fe1e7de717c..87c113a2720bd4f52b5e6216f062ef7825ec8112 100644 --- a/mysql-test/suite/parts/r/partition_alter_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter_innodb.result @@ -47,3 +47,9 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; +create table t1 (i int) engine=InnoDB partition by range(i) (partition p0 values less than (10)); +lock table t1 write; +alter table t1 add partition (partition p0 values less than (20)); +ERROR HY000: Duplicate partition name p0 +alter table t1 add partition (partition p1 values less than (20)) /* comment */; +drop table t1; diff --git a/mysql-test/suite/parts/r/partition_alter_maria.result b/mysql-test/suite/parts/r/partition_alter_maria.result index fd09c0bd4bb1049350eb1619afbfd545fee1afcb..5f1f882d2eadd5d18d370d936bd2cf039698ecbc 100644 --- a/mysql-test/suite/parts/r/partition_alter_maria.result +++ b/mysql-test/suite/parts/r/partition_alter_maria.result @@ -16,6 +16,15 @@ select * from t1; pk dt 1 2017-09-28 15:12:00 drop table t1; +create table t1 (a int) engine=Aria transactional=1 partition by hash(a) partitions 2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 TRANSACTIONAL=1 +/*!50100 PARTITION BY HASH (a) +PARTITIONS 2 */ +drop table t1; # # MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine # @@ -60,3 +69,9 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; +create table t1 (i int) engine=Aria partition by range(i) (partition p0 values less than (10)); +lock table t1 write; +alter table t1 add partition (partition p0 values less than (20)); +ERROR HY000: Duplicate partition name p0 +alter table t1 add partition (partition p1 values less than (20)) /* comment */; +drop table t1; diff --git a/mysql-test/suite/parts/r/partition_alter_myisam.result b/mysql-test/suite/parts/r/partition_alter_myisam.result index 41af6af72fcda359516c8ef610b2d94e40b4014e..4098ebba473f0c19263c4ba7757e2ad3d6e329cc 100644 --- a/mysql-test/suite/parts/r/partition_alter_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter_myisam.result @@ -42,6 +42,12 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; +create table t1 (i int) engine=MyISAM partition by range(i) (partition p0 values less than (10)); +lock table t1 write; +alter table t1 add partition (partition p0 values less than (20)); +ERROR HY000: Duplicate partition name p0 +alter table t1 add partition (partition p1 values less than (20)) /* comment */; +drop table t1; create table t1 ( c1 int, c2 int, c3 varchar(100)) delay_key_write=1 partition by key(c1) ( partition p01 data directory = 'MYSQL_TMP_DIR' diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result index d7a77e5e54aaacb4c5f1cb8eefaac6cdac82ddde..405511543bf5b4feb1dc059e47da1f549c838b40 100644 --- a/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result +++ b/mysql-test/suite/parts/r/partition_basic_symlink_innodb.result @@ -127,5 +127,198 @@ t1#P#p0.ibd t1#P#p1.ibd DROP TABLE t1; # +# MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work +# properly when used with DATA DIRECTORY +# +SET GLOBAL innodb_file_per_table = ON; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY KEY (myid) +( +PARTITION p0001 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir'; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY KEY (myid) +(PARTITION p0001 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0002 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/mysql-test-data-dir/' +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/mysql-test-data-dir/' +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +CREATE TABLE t1 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) +( +PARTITION p0001 VALUES LESS THAN (50) ENGINE = INNODB, +PARTITION p0002 VALUES LESS THAN (150) ENGINE = INNODB, +PARTITION p0003 VALUES LESS THAN (1050) ENGINE = INNODB, +PARTITION p0004 VALUES LESS THAN (10050) ENGINE = INNODB +); +CREATE TABLE t2 +( +myid INT(11) NOT NULL, +myval VARCHAR(10), +PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir'; +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); +select * from t1; +myid myval +1 one +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (myid) +(PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' ENGINE = InnoDB, + PARTITION p0002 VALUES LESS THAN (150) ENGINE = InnoDB, + PARTITION p0003 VALUES LESS THAN (1050) ENGINE = InnoDB, + PARTITION p0004 VALUES LESS THAN (10050) ENGINE = InnoDB) */ +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `myid` int(11) NOT NULL, + `myval` varchar(10) DEFAULT NULL, + PRIMARY KEY (`myid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select * from t1; +myid myval +2 two +3 threee +4 four +select * from t2; +myid myval +1 one +DROP TABLE t1, t2; +# # Cleanup # diff --git a/mysql-test/suite/parts/t/partition_alter_maria.test b/mysql-test/suite/parts/t/partition_alter_maria.test index e21f0dfab82d4fbb2974eea2a7c9a0446915cc58..e0b9256391d4fd24c5644d7f0f2ca7ea1952d51d 100644 --- a/mysql-test/suite/parts/t/partition_alter_maria.test +++ b/mysql-test/suite/parts/t/partition_alter_maria.test @@ -17,5 +17,12 @@ alter table t1 drop partition p20181231; select * from t1; drop table t1; +# +# MDEV-13982 Server crashes in in ha_partition::engine_name +# +create table t1 (a int) engine=Aria transactional=1 partition by hash(a) partitions 2; +show create table t1; +drop table t1; + --let $engine=Aria --source inc/part_alter_values.inc diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test index b2bd0e72e4c7922698d709eb6203ca72772b66de..7e984921c1c2822d5a56ae94207375f5ccd728ab 100644 --- a/mysql-test/suite/parts/t/partition_alter_myisam.test +++ b/mysql-test/suite/parts/t/partition_alter_myisam.test @@ -1,4 +1,5 @@ --source include/have_partition.inc +--source include/have_symlink.inc --let $engine=MyISAM --source inc/part_alter_values.inc diff --git a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test index 35dc2d5e004d304778d995d8b95ada0146a0fb98..31448c7a9fe9efa06b2fec5a637948064d027bcc 100644 --- a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test +++ b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test @@ -147,6 +147,147 @@ SHOW CREATE TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work +--echo # properly when used with DATA DIRECTORY +--echo # +let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir; +let $alt_data_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir; +SET GLOBAL innodb_file_per_table = ON; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY KEY (myid) + ( + PARTITION p0001 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$data_dir_path'; + +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +DROP TABLE t1, t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path'; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB PARTITION BY RANGE (myid) + ( + PARTITION p0001 VALUES LESS THAN (50) ENGINE = INNODB, + PARTITION p0002 VALUES LESS THAN (150) ENGINE = INNODB, + PARTITION p0003 VALUES LESS THAN (1050) ENGINE = INNODB, + PARTITION p0004 VALUES LESS THAN (10050) ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t2 +( + myid INT(11) NOT NULL, + myval VARCHAR(10), + PRIMARY KEY (myid) +) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path'; + +insert into t1 values (1, 'one'); +insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four'); + +select * from t1; +ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t2; +select * from t1; +select * from t2; +DROP TABLE t1, t2; --echo # --echo # Cleanup --echo # @@ -160,5 +301,3 @@ EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig; --enable_query_log - - diff --git a/mysql-test/suite/perfschema/r/hostcache_ipv4_max_con.result b/mysql-test/suite/perfschema/r/hostcache_ipv4_max_con.result index 31e4bc9f8437078c0b0291def8d7eb1a31bad14a..69e1ddb29f576036cdd05d711e0503e5c9874774 100644 --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_max_con.result +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_max_con.result @@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0 FIRST_ERROR_SEEN set LAST_ERROR_SEEN set set global max_user_connections = 0; -set global max_connections = 3; +set global max_connections = 10; flush user_resources; select "Con4a is alive"; Con4a is alive diff --git a/mysql-test/suite/perfschema/r/hostcache_ipv6_max_con.result b/mysql-test/suite/perfschema/r/hostcache_ipv6_max_con.result index 4416b78d0093e0d0cbeb8dc3b2f09d74c9ea5c10..56eb6fe6ac65cee881d4d9cfc1686812e1146f3f 100644 --- a/mysql-test/suite/perfschema/r/hostcache_ipv6_max_con.result +++ b/mysql-test/suite/perfschema/r/hostcache_ipv6_max_con.result @@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0 FIRST_ERROR_SEEN set LAST_ERROR_SEEN set set global max_user_connections = 0; -set global max_connections = 3; +set global max_connections = 10; flush user_resources; select "Con4a is alive"; Con4a is alive diff --git a/mysql-test/suite/perfschema/r/partition.result b/mysql-test/suite/perfschema/r/partition.result new file mode 100644 index 0000000000000000000000000000000000000000..9bc624268bb40eebf6bc10053c415806c4194639 --- /dev/null +++ b/mysql-test/suite/perfschema/r/partition.result @@ -0,0 +1,10 @@ +# +# MDEV-10679 +# Server crashes in in mysql_create_frm_image upon query from +# performance schema in ps-protocol mode +# +CREATE TABLE t1 (i INT); +ALTER TABLE t1 ADD PARTITION (PARTITION p VALUES LESS THAN (1)); +ERROR HY000: Partition management on a not partitioned table is not possible +SELECT * FROM performance_schema.events_stages_summary_by_user_by_event_name; +DROP TABLE t1; diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test index 3bf5ef3b68de4a00f2f7791a46b4d8c62a212781..a76e04ea35e7d0a0e52cb7ae3d610958d827ccc9 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test @@ -176,9 +176,17 @@ disconnect con4c; --source ../include/wait_for_pfs_thread_count.inc set global max_user_connections = 0; -set global max_connections = 3; +set global max_connections = 10; flush user_resources; +connect (tmp_con1,localhost,root,,); +connect (tmp_con2,localhost,root,,); +connect (tmp_con3,localhost,root,,); +connect (tmp_con4,localhost,root,,); +connect (tmp_con5,localhost,root,,); +connect (tmp_con6,localhost,root,,); +connect (tmp_con7,localhost,root,,); + connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,); select "Con4a is alive"; select current_user(); @@ -233,6 +241,13 @@ connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,); disconnect con5a; disconnect con5b; +--disconnect tmp_con1 +--disconnect tmp_con2 +--disconnect tmp_con3 +--disconnect tmp_con4 +--disconnect tmp_con5 +--disconnect tmp_con6 +--disconnect tmp_con7 # Wait for all disconnects --source ../include/wait_for_pfs_thread_count.inc diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test index 0ced79544a30e0ee8938b95bc5404548b16fb9b3..96a5d10d6e180d4443a6107672b110d253d6208f 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test @@ -177,9 +177,17 @@ disconnect con4c; --source ../include/wait_for_pfs_thread_count.inc set global max_user_connections = 0; -set global max_connections = 3; +set global max_connections = 10; flush user_resources; +connect (tmp_con1,localhost,root,,); +connect (tmp_con2,localhost,root,,); +connect (tmp_con3,localhost,root,,); +connect (tmp_con4,localhost,root,,); +connect (tmp_con5,localhost,root,,); +connect (tmp_con6,localhost,root,,); +connect (tmp_con7,localhost,root,,); + connect (con5a,"::1",quota,,test,$MASTER_MYPORT,); select "Con4a is alive"; select current_user(); @@ -215,6 +223,13 @@ connect (con5d,"::1",quota,,test,$MASTER_MYPORT,); disconnect con5a; disconnect con5b; +--disconnect tmp_con1 +--disconnect tmp_con2 +--disconnect tmp_con3 +--disconnect tmp_con4 +--disconnect tmp_con5 +--disconnect tmp_con6 +--disconnect tmp_con7 # Wait for all disconnects --source ../include/wait_for_pfs_thread_count.inc diff --git a/mysql-test/suite/perfschema/t/partition.test b/mysql-test/suite/perfschema/t/partition.test new file mode 100644 index 0000000000000000000000000000000000000000..073a41e92520edc38ceb0660235d0667924a0574 --- /dev/null +++ b/mysql-test/suite/perfschema/t/partition.test @@ -0,0 +1,15 @@ +--source include/have_perfschema.inc + +--echo # +--echo # MDEV-10679 +--echo # Server crashes in in mysql_create_frm_image upon query from +--echo # performance schema in ps-protocol mode +--echo # + +CREATE TABLE t1 (i INT); +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 ADD PARTITION (PARTITION p VALUES LESS THAN (1)); +--disable_result_log +SELECT * FROM performance_schema.events_stages_summary_by_user_by_event_name; +--enable_result_log +DROP TABLE t1; diff --git a/mysql-test/suite/plugins/r/processlist.result b/mysql-test/suite/plugins/r/processlist.result new file mode 100644 index 0000000000000000000000000000000000000000..d08ea9d35234ef3a8b45c672bdf45d83370c42b2 --- /dev/null +++ b/mysql-test/suite/plugins/r/processlist.result @@ -0,0 +1,8 @@ +create table t1 (a int) engine=innodb; +start transaction; +insert t1 values (1); +state from show engine innodb status + +state from show processlist + +drop table t1; diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 3971504b238e53f25c1bfe60cc77e9843f89ed56..5c355b34ba1ec4490b20d5b407e0399075f8327e 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -182,6 +182,17 @@ select 2; 2 2 drop table t1; +set global server_audit_events='query_dml_no_select'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +drop table t1; set global server_audit_events=''; set global server_audit_query_log_limit= 15; select (1), (2), (3), (4); @@ -343,6 +354,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD \n# comment\nFOR u1 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1=',ID TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop user u1, u2, u3',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into t1 values (1), (2)',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_events=\'\'',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global serv',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select (1), (2)',0 diff --git a/mysql-test/suite/plugins/t/processlist.test b/mysql-test/suite/plugins/t/processlist.test new file mode 100644 index 0000000000000000000000000000000000000000..5aacef317b9a7cc2c53db08f938ecdc0d7dfe1db --- /dev/null +++ b/mysql-test/suite/plugins/t/processlist.test @@ -0,0 +1,18 @@ +# +# MDEV-15359 Thread stay in "cleaning up" status after finishing +# +source include/have_innodb.inc; + +create table t1 (a int) engine=innodb; +start transaction; +insert t1 values (1); +let id=`select connection_id()`; +connect con2,localhost,root; +let s=query_get_value(show engine innodb status,Status,1); +disable_query_log; +eval select regexp_replace("$s", '(?s)^.*MySQL thread id $id,.*root([^\n]*)\n.*', '\\\\1') as `state from show engine innodb status`; +eval select state as `state from show processlist` from information_schema.processlist where id = $id; +enable_query_log; +disconnect con2; +connection default; +drop table t1; diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index 9be0d5556f005e0613ce693fa771ae57958b58db..4af1ed883e38fe824c8264ea39e9481b4127cd2b 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -42,8 +42,10 @@ select 1, 3; insert into t2 values (1), (2); select * from t2; +--disable_ps_protocol --error ER_NO_SUCH_TABLE select * from t_doesnt_exist; +--enable_ps_protocol --error 1064 syntax_error_query; drop table renamed_t1, t2; @@ -119,6 +121,13 @@ select 2; /*! select 2*/; /*comment*/ select 2; drop table t1; +set global server_audit_events='query_dml_no_select'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; + set global server_audit_events=''; set global server_audit_query_log_limit= 15; diff --git a/mysql-test/suite/rpl/r/rename.result b/mysql-test/suite/rpl/r/rename.result new file mode 100644 index 0000000000000000000000000000000000000000..5cedea51c8665203b874d33414d18223b497742a --- /dev/null +++ b/mysql-test/suite/rpl/r/rename.result @@ -0,0 +1,34 @@ +include/master-slave.inc +[connection master] +# +# MDEV-16229 Replication aborts with ER_VIEW_SELECT_TMPTABLE after +# half-failed RENAME +# +CREATE TABLE t1 (a INT); +CREATE TEMPORARY TABLE t1 (b INT); +RENAME TABLE t1 TO tmp, tmp TO t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE VIEW v AS SELECT * FROM t1; +ERROR HY000: View's SELECT refers to a temporary table 't1' +RENAME TABLE t1 TO tmp, t1 TO t2; +SHOW CREATE TABLE tmp; +Table Create Table +tmp CREATE TEMPORARY TABLE `tmp` ( + `b` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE VIEW v AS SELECT * FROM tmp; +ERROR HY000: View's SELECT refers to a temporary table 'tmp' +CREATE VIEW v AS SELECT * FROM t2; +DROP VIEW v; +DROP TABLE tmp; +DROP TABLE t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result index 328c3c3423fc7950b8b4e1126cae3cd792a35180..7efb1f7162bd2f43c19a21a790aa463ee8499b6f 100644 --- a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result @@ -13,612 +13,319 @@ INSERT INTO tt_2(ddl_case) VALUES(0); # CHECK IMPLICT COMMIT ######################################################################### SET AUTOCOMMIT= 0; --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (43); CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (42); DROP FUNCTION myfunc_int; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (41); LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; Table Op Msg_type Msg_text test.nt_1 preload_keys status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (40); LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; Table Op Msg_type Msg_text test.tt_1 preload_keys note The storage engine for the table doesn't support preload_keys test.tt_2 preload_keys note The storage engine for the table doesn't support preload_keys --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (39); ANALYZE TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 analyze status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; ANALYZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (38); CHECK TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 check status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (38) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (37); OPTIMIZE TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 optimize status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- +INSERT INTO tt_1(ddl_case) VALUES (36); +REPAIR TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 repair status OK +INSERT INTO tt_1(ddl_case) VALUES (35); +LOCK TABLES tt_1 WRITE; +INSERT INTO tt_1(ddl_case) VALUES (34); +UNLOCK TABLES; +INSERT INTO tt_1(ddl_case) VALUES (33); +CREATE USER 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (32); +GRANT ALL ON *.* TO 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (31); +SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); +INSERT INTO tt_1(ddl_case) VALUES (30); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (29); +RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (28); +DROP USER 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (27); +CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (26); +ALTER EVENT evt COMMENT 'evt'; +INSERT INTO tt_1(ddl_case) VALUES (25); +DROP EVENT evt; +INSERT INTO tt_1(ddl_case) VALUES (24); +CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (23); +DROP TRIGGER tr; +INSERT INTO tt_1(ddl_case) VALUES (22); +CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; +INSERT INTO tt_1(ddl_case) VALUES (21); +ALTER FUNCTION fc COMMENT 'fc'; +INSERT INTO tt_1(ddl_case) VALUES (20); +DROP FUNCTION fc; +INSERT INTO tt_1(ddl_case) VALUES (19); +CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (18); +ALTER PROCEDURE pc COMMENT 'pc'; +INSERT INTO tt_1(ddl_case) VALUES (17); +DROP PROCEDURE pc; +INSERT INTO tt_1(ddl_case) VALUES (16); +CREATE VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (15); +ALTER VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (14); +DROP VIEW v; +INSERT INTO tt_1(ddl_case) VALUES (13); +CREATE INDEX ix ON tt_1(ddl_case); +INSERT INTO tt_1(ddl_case) VALUES (12); +DROP INDEX ix ON tt_1; +INSERT INTO tt_1(ddl_case) VALUES (11); +CREATE TEMPORARY TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (10); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (9); +ALTER TABLE tt_xx RENAME new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (8); +DROP TEMPORARY TABLE IF EXISTS new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (7); +CREATE TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (6); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (5); +RENAME TABLE tt_xx TO new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (4); +TRUNCATE TABLE new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (3); +DROP TABLE IF EXISTS tt_xx, new_tt_xx; +Warnings: +Note 1051 Unknown table 'test.tt_xx' +INSERT INTO tt_1(ddl_case) VALUES (2); +CREATE DATABASE db; +INSERT INTO tt_1(ddl_case) VALUES (1); +DROP DATABASE IF EXISTS db; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_2 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE nt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = MyIsam +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES(0) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_2(ddl_case) VALUES(0) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB" +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; ANALYZE TABLE nt_1 +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (38) +master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (37) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; OPTIMIZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (36); -REPAIR TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 repair status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (36) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REPAIR TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (35); -LOCK TABLES tt_1 WRITE; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (35) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (34); -UNLOCK TABLES; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (34) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (33); -CREATE USER 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (33) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE USER 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (32); -GRANT ALL ON *.* TO 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (32) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; GRANT ALL ON *.* TO 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (31); -SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (31) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (30); -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (30) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (29); -RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (29) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME USER 'user'@'localhost' TO 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (28); -DROP USER 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (28) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP USER 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (27); -CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (27) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (26); -ALTER EVENT evt COMMENT 'evt'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (26) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER EVENT evt COMMENT 'evt' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (25); -DROP EVENT evt; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (25) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP EVENT evt --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (24); -CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (24) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (23); -DROP TRIGGER tr; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (23) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TRIGGER tr --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (22); -CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (22) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `fc`() RETURNS varchar(64) CHARSET latin1 RETURN "fc" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (21); -ALTER FUNCTION fc COMMENT 'fc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (21) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER FUNCTION fc COMMENT 'fc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (20); -DROP FUNCTION fc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (20) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION fc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (19); -CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (19) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `pc`() UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (18); -ALTER PROCEDURE pc COMMENT 'pc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (18) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER PROCEDURE pc COMMENT 'pc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (17); -DROP PROCEDURE pc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (17) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP PROCEDURE pc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (16); -CREATE VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (16) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (15); -ALTER VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (15) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (14); -DROP VIEW v; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (14) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP VIEW v --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (13); -CREATE INDEX ix ON tt_1(ddl_case); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (13) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE INDEX ix ON tt_1(ddl_case) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (12); -DROP INDEX ix ON tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (12) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP INDEX ix ON tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (11); -CREATE TEMPORARY TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (11) master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tt_xx (a int) +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (10) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (10); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (9); -ALTER TABLE tt_xx RENAME new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx ADD COLUMN (b int) master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (9) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (8); -DROP TEMPORARY TABLE IF EXISTS new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx RENAME new_tt_xx master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (8) master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`new_tt_xx` /* generated by server */ -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (7); -CREATE TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (7) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE tt_xx (a int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (6); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (6) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx ADD COLUMN (b int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (5); -RENAME TABLE tt_xx TO new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (5) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME TABLE tt_xx TO new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (4); -TRUNCATE TABLE new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (4) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; TRUNCATE TABLE new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (3); -DROP TABLE IF EXISTS tt_xx, new_tt_xx; -Warnings: -Note 1051 Unknown table 'test.tt_xx' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (3) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `tt_xx`,`new_tt_xx` /* generated by server */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (2); -CREATE DATABASE db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (2) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # CREATE DATABASE db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (1); -DROP DATABASE IF EXISTS db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (1) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP DATABASE IF EXISTS db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - +SET AUTOCOMMIT= 1; ################################################################################### # CHECK CONSISTENCY ################################################################################### @@ -626,4 +333,7 @@ include/diff_tables.inc [master:tt_1,slave:tt_1] ################################################################################### # CLEAN ################################################################################### +DROP TABLE tt_1; +DROP TABLE tt_2; +DROP TABLE nt_1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_parallel_optimistic.result b/mysql-test/suite/rpl/r/rpl_parallel_optimistic.result index 0177e65b10f17022f5abdbe7ceb4460575d1df68..a6da3399fab37c1e885dfe83490573adc8283c42 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_optimistic.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_optimistic.result @@ -1,4 +1,6 @@ include/rpl_init.inc [topology=1->2] +call mtr.add_suppression("Warning.*Deadlock found when trying to get lock; try restarting transaction"); +call mtr.add_suppression("Warning.*mysqld: Can't find record in 't2'"); ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; @@ -543,6 +545,27 @@ a b 57 7 58 8 59 9 +DELETE FROM t1; +DELETE FROM t2; +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +BEGIN; +INSERT INTO t1 SET a=1; +SET @save.binlog_format=@@session.binlog_format; +SET @@SESSION.binlog_format=row; +BEGIN; +INSERT INTO t1 SET a=1; +INSERT INTO t2 SET a=1; +COMMIT; +BEGIN; +DELETE FROM t2; +COMMIT; +ROLLBACK; +SET @@SESSION.binlog_format= @save.binlog_format; +DELETE FROM t1; +DELETE FROM t2; +include/save_master_gtid.inc +include/sync_with_master_gtid.inc include/stop_slave.inc SET GLOBAL slave_parallel_mode=@old_parallel_mode; SET GLOBAL slave_parallel_threads=@old_parallel_threads; diff --git a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result index 95167311c3f1795ef56f873ec5557f8170ab39fb..1618ee3185e129033a1874dc97e6ea968a9e708e 100644 --- a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result @@ -13,316 +13,229 @@ INSERT INTO tt_2(ddl_case) VALUES(0); # CHECK IMPLICT COMMIT ######################################################################### SET AUTOCOMMIT= 0; --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (43); CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- +INSERT INTO tt_1(ddl_case) VALUES (42); +DROP FUNCTION myfunc_int; +INSERT INTO tt_1(ddl_case) VALUES (41); +LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; +Table Op Msg_type Msg_text +test.nt_1 preload_keys status OK +INSERT INTO tt_1(ddl_case) VALUES (40); +LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; +Table Op Msg_type Msg_text +test.tt_1 preload_keys note The storage engine for the table doesn't support preload_keys +test.tt_2 preload_keys note The storage engine for the table doesn't support preload_keys +INSERT INTO tt_1(ddl_case) VALUES (39); +ANALYZE TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 analyze status Table is already up to date +INSERT INTO tt_1(ddl_case) VALUES (38); +CHECK TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 check status OK +INSERT INTO tt_1(ddl_case) VALUES (37); +OPTIMIZE TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 optimize status Table is already up to date +INSERT INTO tt_1(ddl_case) VALUES (36); +REPAIR TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 repair status OK +INSERT INTO tt_1(ddl_case) VALUES (35); +LOCK TABLES tt_1 WRITE; +INSERT INTO tt_1(ddl_case) VALUES (34); +UNLOCK TABLES; +INSERT INTO tt_1(ddl_case) VALUES (33); +CREATE USER 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (32); +GRANT ALL ON *.* TO 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (31); +SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); +INSERT INTO tt_1(ddl_case) VALUES (30); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (29); +RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (28); +DROP USER 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (27); +CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (26); +ALTER EVENT evt COMMENT 'evt'; +INSERT INTO tt_1(ddl_case) VALUES (25); +DROP EVENT evt; +INSERT INTO tt_1(ddl_case) VALUES (24); +CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (23); +DROP TRIGGER tr; +INSERT INTO tt_1(ddl_case) VALUES (22); +CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; +INSERT INTO tt_1(ddl_case) VALUES (21); +ALTER FUNCTION fc COMMENT 'fc'; +INSERT INTO tt_1(ddl_case) VALUES (20); +DROP FUNCTION fc; +INSERT INTO tt_1(ddl_case) VALUES (19); +CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (18); +ALTER PROCEDURE pc COMMENT 'pc'; +INSERT INTO tt_1(ddl_case) VALUES (17); +DROP PROCEDURE pc; +INSERT INTO tt_1(ddl_case) VALUES (16); +CREATE VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (15); +ALTER VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (14); +DROP VIEW v; +INSERT INTO tt_1(ddl_case) VALUES (13); +CREATE INDEX ix ON tt_1(ddl_case); +INSERT INTO tt_1(ddl_case) VALUES (12); +DROP INDEX ix ON tt_1; +INSERT INTO tt_1(ddl_case) VALUES (11); +CREATE TEMPORARY TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (10); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (9); +ALTER TABLE tt_xx RENAME new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (8); +DROP TEMPORARY TABLE IF EXISTS new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (7); +CREATE TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (6); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (5); +RENAME TABLE tt_xx TO new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (4); +TRUNCATE TABLE new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (3); +DROP TABLE IF EXISTS tt_xx, new_tt_xx; +Warnings: +Note 1051 Unknown table 'test.tt_xx' +INSERT INTO tt_1(ddl_case) VALUES (2); +CREATE DATABASE db; +INSERT INTO tt_1(ddl_case) VALUES (1); +DROP DATABASE IF EXISTS db; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_2 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE nt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = MyIsam +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Table_map # # table_id: # (test.tt_1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Table_map # # table_id: # (test.tt_2) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (42); -DROP FUNCTION myfunc_int; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (41); -LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; -Table Op Msg_type Msg_text -test.nt_1 preload_keys status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (40); -LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; -Table Op Msg_type Msg_text -test.tt_1 preload_keys note The storage engine for the table doesn't support preload_keys -test.tt_2 preload_keys note The storage engine for the table doesn't support preload_keys --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (39); -ANALYZE TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 analyze status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ANALYZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (38); -CHECK TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 check status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (37); -OPTIMIZE TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 optimize status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; OPTIMIZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (36); -REPAIR TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 repair status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REPAIR TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (35); -LOCK TABLES tt_1 WRITE; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (34); -UNLOCK TABLES; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (33); -CREATE USER 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE USER 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (32); -GRANT ALL ON *.* TO 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; GRANT ALL ON *.* TO 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (31); -SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (30); -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (29); -RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME USER 'user'@'localhost' TO 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (28); -DROP USER 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP USER 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (27); -CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (26); -ALTER EVENT evt COMMENT 'evt'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER EVENT evt COMMENT 'evt' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (25); -DROP EVENT evt; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP EVENT evt --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (24); -CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (23); -DROP TRIGGER tr; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Table_map # # table_id: # (test.tt_2) @@ -330,15 +243,6 @@ master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TRIGGER tr --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (22); -CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F @@ -346,45 +250,18 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `fc`() RETURNS varchar(64) CHARSET latin1 RETURN "fc" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (21); -ALTER FUNCTION fc COMMENT 'fc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER FUNCTION fc COMMENT 'fc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (20); -DROP FUNCTION fc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION fc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (19); -CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F @@ -392,272 +269,103 @@ master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `pc`() UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (18); -ALTER PROCEDURE pc COMMENT 'pc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER PROCEDURE pc COMMENT 'pc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (17); -DROP PROCEDURE pc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP PROCEDURE pc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (16); -CREATE VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (15); -ALTER VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (14); -DROP VIEW v; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP VIEW v --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (13); -CREATE INDEX ix ON tt_1(ddl_case); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE INDEX ix ON tt_1(ddl_case) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (12); -DROP INDEX ix ON tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP INDEX ix ON tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (11); -CREATE TEMPORARY TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (10); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (9); -ALTER TABLE tt_xx RENAME new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (8); -DROP TEMPORARY TABLE IF EXISTS new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (7); -CREATE TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE tt_xx (a int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (6); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx ADD COLUMN (b int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (5); -RENAME TABLE tt_xx TO new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME TABLE tt_xx TO new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (4); -TRUNCATE TABLE new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; TRUNCATE TABLE new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (3); -DROP TABLE IF EXISTS tt_xx, new_tt_xx; -Warnings: -Note 1051 Unknown table 'test.tt_xx' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `tt_xx`,`new_tt_xx` /* generated by server */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (2); -CREATE DATABASE db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # CREATE DATABASE db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (1); -DROP DATABASE IF EXISTS db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP DATABASE IF EXISTS db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - +SET AUTOCOMMIT= 1; ################################################################################### # CHECK CONSISTENCY ################################################################################### @@ -665,4 +373,7 @@ include/diff_tables.inc [master:tt_1,slave:tt_1] ################################################################################### # CLEAN ################################################################################### +DROP TABLE tt_1; +DROP TABLE tt_2; +DROP TABLE nt_1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_skip_repl.result b/mysql-test/suite/rpl/r/rpl_semi_sync_skip_repl.result new file mode 100644 index 0000000000000000000000000000000000000000..4762ac8dd07e27aa5de3bdecc6b4c76277e91b52 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_skip_repl.result @@ -0,0 +1,23 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Timeout waiting for reply of binlog"); +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +SET @@GLOBAL.rpl_semi_sync_master_timeout=100; +include/stop_slave.inc +SET @@GLOBAL.replicate_events_marked_for_skip=FILTER_ON_MASTER; +SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1; +include/start_slave.inc +CREATE TABLE t1 (a INT) ENGINE=innodb; +SET @@GLOBAL.debug_dbug= "d,dbug_master_binlog_over_2GB"; +SET @@SESSION.skip_replication=1; +INSERT INTO t1 SET a=1; +SET @@SESSION.skip_replication=0; +INSERT INTO t1 SET a=0; +SET @@GLOBAL.debug_dbug=""; +SET @@GLOBAL. rpl_semi_sync_master_timeout = 10000; +SET @@GLOBAL. rpl_semi_sync_master_enabled = 0; +DROP TABLE t1; +include/stop_slave.inc +SET @@GLOBAL. rpl_semi_sync_slave_enabled = 0; +SET @@GLOBAL.replicate_events_marked_for_skip = REPLICATE; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result index cb702ad64effd03b5d3363033028c5e466628263..7efb1f7162bd2f43c19a21a790aa463ee8499b6f 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result @@ -13,613 +13,319 @@ INSERT INTO tt_2(ddl_case) VALUES(0); # CHECK IMPLICT COMMIT ######################################################################### SET AUTOCOMMIT= 0; --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (43); CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (42); DROP FUNCTION myfunc_int; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (41); LOAD INDEX INTO CACHE nt_1 IGNORE LEAVES; Table Op Msg_type Msg_text test.nt_1 preload_keys status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (40); LOAD INDEX INTO CACHE tt_1, tt_2 IGNORE LEAVES; Table Op Msg_type Msg_text test.tt_1 preload_keys note The storage engine for the table doesn't support preload_keys test.tt_2 preload_keys note The storage engine for the table doesn't support preload_keys --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (39); ANALYZE TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 analyze status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; ANALYZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (38); CHECK TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 check status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (38) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- INSERT INTO tt_1(ddl_case) VALUES (37); OPTIMIZE TABLE nt_1; Table Op Msg_type Msg_text test.nt_1 optimize status Table is already up to date --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- +INSERT INTO tt_1(ddl_case) VALUES (36); +REPAIR TABLE nt_1; +Table Op Msg_type Msg_text +test.nt_1 repair status OK +INSERT INTO tt_1(ddl_case) VALUES (35); +LOCK TABLES tt_1 WRITE; +INSERT INTO tt_1(ddl_case) VALUES (34); +UNLOCK TABLES; +INSERT INTO tt_1(ddl_case) VALUES (33); +CREATE USER 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (32); +GRANT ALL ON *.* TO 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (31); +SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); +INSERT INTO tt_1(ddl_case) VALUES (30); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (29); +RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (28); +DROP USER 'user_new'@'localhost'; +INSERT INTO tt_1(ddl_case) VALUES (27); +CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (26); +ALTER EVENT evt COMMENT 'evt'; +INSERT INTO tt_1(ddl_case) VALUES (25); +DROP EVENT evt; +INSERT INTO tt_1(ddl_case) VALUES (24); +CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (23); +DROP TRIGGER tr; +INSERT INTO tt_1(ddl_case) VALUES (22); +CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; +INSERT INTO tt_1(ddl_case) VALUES (21); +ALTER FUNCTION fc COMMENT 'fc'; +INSERT INTO tt_1(ddl_case) VALUES (20); +DROP FUNCTION fc; +INSERT INTO tt_1(ddl_case) VALUES (19); +CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; +INSERT INTO tt_1(ddl_case) VALUES (18); +ALTER PROCEDURE pc COMMENT 'pc'; +INSERT INTO tt_1(ddl_case) VALUES (17); +DROP PROCEDURE pc; +INSERT INTO tt_1(ddl_case) VALUES (16); +CREATE VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (15); +ALTER VIEW v AS SELECT * FROM tt_1; +INSERT INTO tt_1(ddl_case) VALUES (14); +DROP VIEW v; +INSERT INTO tt_1(ddl_case) VALUES (13); +CREATE INDEX ix ON tt_1(ddl_case); +INSERT INTO tt_1(ddl_case) VALUES (12); +DROP INDEX ix ON tt_1; +INSERT INTO tt_1(ddl_case) VALUES (11); +CREATE TEMPORARY TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (10); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (9); +ALTER TABLE tt_xx RENAME new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (8); +DROP TEMPORARY TABLE IF EXISTS new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (7); +CREATE TABLE tt_xx (a int); +INSERT INTO tt_1(ddl_case) VALUES (6); +ALTER TABLE tt_xx ADD COLUMN (b int); +INSERT INTO tt_1(ddl_case) VALUES (5); +RENAME TABLE tt_xx TO new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (4); +TRUNCATE TABLE new_tt_xx; +INSERT INTO tt_1(ddl_case) VALUES (3); +DROP TABLE IF EXISTS tt_xx, new_tt_xx; +Warnings: +Note 1051 Unknown table 'test.tt_xx' +INSERT INTO tt_1(ddl_case) VALUES (2); +CREATE DATABASE db; +INSERT INTO tt_1(ddl_case) VALUES (1); +DROP DATABASE IF EXISTS db; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tt_2 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = Innodb +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE nt_1 (ddl_case INT, PRIMARY KEY(ddl_case)) ENGINE = MyIsam +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES(0) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_2(ddl_case) VALUES(0) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (43) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "LIB" +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (42) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; ANALYZE TABLE nt_1 +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (38) +master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (37) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; OPTIMIZE TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (36); -REPAIR TABLE nt_1; -Table Op Msg_type Msg_text -test.nt_1 repair status OK --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (36) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REPAIR TABLE nt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (35); -LOCK TABLES tt_1 WRITE; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (35) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (34); -UNLOCK TABLES; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (34) master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (33); -CREATE USER 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (33) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE USER 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (32); -GRANT ALL ON *.* TO 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (32) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; GRANT ALL ON *.* TO 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (31); -SET PASSWORD FOR 'user'@'localhost' = PASSWORD('newpass'); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (31) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (30); -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (30) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (29); -RENAME USER 'user'@'localhost' TO 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (29) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME USER 'user'@'localhost' TO 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (28); -DROP USER 'user_new'@'localhost'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (28) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP USER 'user_new'@'localhost' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (27); -CREATE EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (27) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT evt ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (26); -ALTER EVENT evt COMMENT 'evt'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (26) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER EVENT evt COMMENT 'evt' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (25); -DROP EVENT evt; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (25) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP EVENT evt --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (24); -CREATE TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (24) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON tt_1 FOR EACH ROW UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (23); -DROP TRIGGER tr; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (23) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TRIGGER tr --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (22); -CREATE FUNCTION fc () RETURNS VARCHAR(64) RETURN "fc"; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (22) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `fc`() RETURNS varchar(64) CHARSET latin1 RETURN "fc" --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (21); -ALTER FUNCTION fc COMMENT 'fc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (21) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER FUNCTION fc COMMENT 'fc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (20); -DROP FUNCTION fc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (20) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION fc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (19); -CREATE PROCEDURE pc () UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (19) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `pc`() UPDATE tt_2 SET ddl_case = ddl_case WHERE ddl_case= NEW.ddl_case --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (18); -ALTER PROCEDURE pc COMMENT 'pc'; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (18) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER PROCEDURE pc COMMENT 'pc' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (17); -DROP PROCEDURE pc; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (17) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP PROCEDURE pc --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (16); -CREATE VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (16) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (15); -ALTER VIEW v AS SELECT * FROM tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (15) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS SELECT * FROM tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (14); -DROP VIEW v; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (14) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP VIEW v --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (13); -CREATE INDEX ix ON tt_1(ddl_case); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (13) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE INDEX ix ON tt_1(ddl_case) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (12); -DROP INDEX ix ON tt_1; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (12) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP INDEX ix ON tt_1 --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (11); -CREATE TEMPORARY TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (11) master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tt_xx (a int) -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (10); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (10) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx ADD COLUMN (b int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (9); -ALTER TABLE tt_xx RENAME new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (9) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx RENAME new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (8); -DROP TEMPORARY TABLE IF EXISTS new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (8) master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`new_tt_xx` /* generated by server */ -master-bin.000001 # Xid # # COMMIT /* XID */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (7); -CREATE TABLE tt_xx (a int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (7) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE tt_xx (a int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (6); -ALTER TABLE tt_xx ADD COLUMN (b int); --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (6) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; ALTER TABLE tt_xx ADD COLUMN (b int) --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (5); -RENAME TABLE tt_xx TO new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (5) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; RENAME TABLE tt_xx TO new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (4); -TRUNCATE TABLE new_tt_xx; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (4) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; TRUNCATE TABLE new_tt_xx --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (3); -DROP TABLE IF EXISTS tt_xx, new_tt_xx; -Warnings: -Note 1051 Unknown table 'test.tt_xx' --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (3) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `tt_xx`,`new_tt_xx` /* generated by server */ --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (2); -CREATE DATABASE db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (2) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # CREATE DATABASE db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -INSERT INTO tt_1(ddl_case) VALUES (1); -DROP DATABASE IF EXISTS db; --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- --b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (1) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # DROP DATABASE IF EXISTS db --e-e-e-e-e-e-e-e-e-e-e- >> << -e-e-e-e-e-e-e-e-e-e-e- - +SET AUTOCOMMIT= 1; ################################################################################### # CHECK CONSISTENCY ################################################################################### @@ -627,4 +333,7 @@ include/diff_tables.inc [master:tt_1,slave:tt_1] ################################################################################### # CLEAN ################################################################################### +DROP TABLE tt_1; +DROP TABLE tt_2; +DROP TABLE nt_1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rename.test b/mysql-test/suite/rpl/t/rename.test new file mode 100644 index 0000000000000000000000000000000000000000..ac499157918f18da9afb82cf203951c6b118c8ce --- /dev/null +++ b/mysql-test/suite/rpl/t/rename.test @@ -0,0 +1,33 @@ +--source include/have_binlog_format_mixed.inc +--source include/master-slave.inc + +--echo # +--echo # MDEV-16229 Replication aborts with ER_VIEW_SELECT_TMPTABLE after +--echo # half-failed RENAME +--echo # + +CREATE TABLE t1 (a INT); +CREATE TEMPORARY TABLE t1 (b INT); +RENAME TABLE t1 TO tmp, tmp TO t1; +SHOW CREATE TABLE t1; +--error ER_VIEW_SELECT_TMPTABLE +CREATE VIEW v AS SELECT * FROM t1; + +RENAME TABLE t1 TO tmp, t1 TO t2; +SHOW CREATE TABLE tmp; +SHOW CREATE TABLE t2; +--error ER_VIEW_SELECT_TMPTABLE +CREATE VIEW v AS SELECT * FROM tmp; +CREATE VIEW v AS SELECT * FROM t2; + +--sync_slave_with_master + +# Cleanup + +--connection master + +DROP VIEW v; +DROP TABLE tmp; +DROP TABLE t2; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_optimistic.test b/mysql-test/suite/rpl/t/rpl_parallel_optimistic.test index 41fb6ebb72e73924987aabb40cfc303aba2316a7..28bf4a77fd4e58f7c1d5a7dbf3679f743b0c97f3 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_optimistic.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_optimistic.test @@ -4,6 +4,11 @@ --let $rpl_topology=1->2 --source include/rpl_init.inc +--connection server_2 +call mtr.add_suppression("Warning.*Deadlock found when trying to get lock; try restarting transaction"); +# The following instruction is a part of the proof of MDEV-13577 fixes, below. +call mtr.add_suppression("Warning.*mysqld: Can't find record in 't2'"); + --connection server_1 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; @@ -480,8 +485,65 @@ SELECT * FROM t2 WHERE a >= 40 ORDER BY a; SELECT * FROM t1 WHERE a >= 40 ORDER BY a; SELECT * FROM t2 WHERE a >= 40 ORDER BY a; -# Clean up. +# partial cleanup to reuse the tables by following tests +--connection server_1 +DELETE FROM t1; +DELETE FROM t2; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +# +# MDEV-13577 optimistic parallel slave errors out to error log unnecessary +# + +# The 1st of the following two trx:s a blocker on slave +--connection server_2 +BEGIN; +INSERT INTO t1 SET a=1; + +--connection server_1 +SET @save.binlog_format=@@session.binlog_format; +SET @@SESSION.binlog_format=row; + +BEGIN; + INSERT INTO t1 SET a=1; + INSERT INTO t2 SET a=1; +COMMIT; + +# This transaction is going to win optimistical race with above INSERT +# on slave while being depend on it. That means it will face a kind of temporary error +# and then will retry to succeed. +BEGIN; + DELETE FROM t2; +COMMIT; + +# First make sure DELETE raced indeed to get stuck at retrying stage +# where it runs "realistically" now. There is nomore optimistic error +# in the errorlog, which is downgraded to the warning level (when +# --log-warnings > 1), see above suppression. +--connection server_2 +--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit" +--source include/wait_condition.inc + +# Next release the 1st trx to commit. +--connection server_2 +ROLLBACK; + +# MDEV-13577 local cleanup: +--connection server_1 +SET @@SESSION.binlog_format= @save.binlog_format; +DELETE FROM t1; +DELETE FROM t2; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc + +# +# Clean up. +# --connection server_2 --source include/stop_slave.inc SET GLOBAL slave_parallel_mode=@old_parallel_mode; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_skip_repl.test b/mysql-test/suite/rpl/t/rpl_semi_sync_skip_repl.test new file mode 100644 index 0000000000000000000000000000000000000000..2f6da18067c6b5528d53a12dcf42d8cae4eebba6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_skip_repl.test @@ -0,0 +1,62 @@ +# MDEV-14721 Big transaction events get lost on semisync master when +# replicate_events_marked_for_skip=FILTER_ON_MASTER +# +# When events of a big transaction are binlogged offsetting over 2GB from +# the beginning of the log the semisync master's dump thread +# lost such events. +# The test verifies the fixes' correctness simulating the 2GB offset. + +source include/have_semisync.inc; +source include/not_embedded.inc; +source include/have_innodb.inc; +source include/have_debug.inc; +source include/master-slave.inc; + +--connection master +# Suppress warnings that might be generated during the test +call mtr.add_suppression("Timeout waiting for reply of binlog"); + +--let $sav_enabled_master=`SELECT @@GLOBAL.rpl_semi_sync_master_enabled ` +--let $sav_timeout_master=`SELECT @@GLOBAL.rpl_semi_sync_master_timeout ` +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +SET @@GLOBAL.rpl_semi_sync_master_timeout=100; + +--connection slave +source include/stop_slave.inc; +--let $sav_skip_marked_slave=`SELECT @@GLOBAL.replicate_events_marked_for_skip ` +SET @@GLOBAL.replicate_events_marked_for_skip=FILTER_ON_MASTER; +--let $sav_enabled_slave=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled ` +SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1; + +source include/start_slave.inc; + +--connection master +CREATE TABLE t1 (a INT) ENGINE=innodb; + +# Make the following events as if they offset over 2GB from the beginning of binlog +SET @@GLOBAL.debug_dbug= "d,dbug_master_binlog_over_2GB"; +SET @@SESSION.skip_replication=1; +INSERT INTO t1 SET a=1; +SET @@SESSION.skip_replication=0; +INSERT INTO t1 SET a=0; + +--sync_slave_with_master + +# +# Clean up +# +--connection master +SET @@GLOBAL.debug_dbug=""; +--eval SET @@GLOBAL. rpl_semi_sync_master_timeout = $sav_timeout_master +--eval SET @@GLOBAL. rpl_semi_sync_master_enabled = $sav_enabled_master + +--connection master +DROP TABLE t1; + +--sync_slave_with_master +source include/stop_slave.inc; +--eval SET @@GLOBAL. rpl_semi_sync_slave_enabled = $sav_enabled_slave +--eval SET @@GLOBAL.replicate_events_marked_for_skip = $sav_skip_marked_slave + +--let $rpl_only_running_threads= 1 +--source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result b/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result new file mode 100644 index 0000000000000000000000000000000000000000..971b8b9d24341a94b6a244e65261df3a20042e3f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_default_row_format_basic.result @@ -0,0 +1,48 @@ +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'redundant'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +redundant +SET GLOBAL innodb_default_row_format = 'dynamic'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 'compact'; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'compressed'; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of 'compressed' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 'foobar'; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of 'foobar' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 0; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +redundant +SET GLOBAL innodb_default_row_format = 1; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +compact +SET GLOBAL innodb_default_row_format = 2; +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 3; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of '3' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = 123; +ERROR 42000: Variable 'innodb_default_row_format' can't be set to the value of '123' +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SET GLOBAL innodb_default_row_format = default; diff --git a/mysql-test/suite/sys_vars/r/max_connections_basic.result b/mysql-test/suite/sys_vars/r/max_connections_basic.result index 708342b016d0a49aa9f240b9b65cad0b55b53967..f9b2c0344000ba18643d0d15b5e28087aa727b95 100644 --- a/mysql-test/suite/sys_vars/r/max_connections_basic.result +++ b/mysql-test/suite/sys_vars/r/max_connections_basic.result @@ -27,20 +27,24 @@ SELECT @@global.max_connections; @@global.max_connections 65536 SET @@global.max_connections = 1; +Warnings: +Warning 1292 Truncated incorrect max_connections value: '1' SELECT @@global.max_connections; @@global.max_connections -1 +10 SET @@global.max_connections = 2; +Warnings: +Warning 1292 Truncated incorrect max_connections value: '2' SELECT @@global.max_connections; @@global.max_connections -2 +10 '#--------------------FN_DYNVARS_074_04-------------------------#' SET @@global.max_connections = -1; Warnings: Warning 1292 Truncated incorrect max_connections value: '-1' SELECT @@global.max_connections; @@global.max_connections -1 +10 SET @@global.max_connections = 100000000000; Warnings: Warning 1292 Truncated incorrect max_connections value: '100000000000' @@ -57,13 +61,13 @@ Warnings: Warning 1292 Truncated incorrect max_connections value: '-1024' SELECT @@global.max_connections; @@global.max_connections -1 +10 SET @@global.max_connections = 0; Warnings: Warning 1292 Truncated incorrect max_connections value: '0' SELECT @@global.max_connections; @@global.max_connections -1 +10 SET @@global.max_connections = 100001; Warnings: Warning 1292 Truncated incorrect max_connections value: '100001' @@ -98,15 +102,17 @@ WHERE VARIABLE_NAME='max_connections'; 1 '#---------------------FN_DYNVARS_074_07----------------------#' SET @@global.max_connections = TRUE; +Warnings: +Warning 1292 Truncated incorrect max_connections value: '1' SELECT @@global.max_connections; @@global.max_connections -1 +10 SET @@global.max_connections = FALSE; Warnings: Warning 1292 Truncated incorrect max_connections value: '0' SELECT @@global.max_connections; @@global.max_connections -1 +10 '#---------------------FN_DYNVARS_074_08----------------------#' SET @@global.max_connections = 5000; SELECT @@max_connections = @@global.max_connections; diff --git a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result index 9419f25193025e8322fc7d5534e79c85d20c89f8..d3de7707f84996de864f09a69a36515e2ce7af75 100644 --- a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result +++ b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result @@ -46,40 +46,40 @@ Warnings: Warning 1292 Truncated incorrect max_prepared_stmt_count value: '100000000000' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 +4294967295 SET @@global.max_prepared_stmt_count = 10000.01; ERROR 42000: Incorrect argument type to variable 'max_prepared_stmt_count' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 +4294967295 SET @@global.max_prepared_stmt_count = -1024; Warnings: Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1024' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count 0 -SET @@global.max_prepared_stmt_count = 1048577; +SET @@global.max_prepared_stmt_count = 4294967296; Warnings: -Warning 1292 Truncated incorrect max_prepared_stmt_count value: '1048577' +Warning 1292 Truncated incorrect max_prepared_stmt_count value: '4294967296' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 -SET @@global.max_prepared_stmt_count = 104857612; +4294967295 +SET @@global.max_prepared_stmt_count = 4294967295*1024; Warnings: -Warning 1292 Truncated incorrect max_prepared_stmt_count value: '104857612' +Warning 1292 Truncated incorrect max_prepared_stmt_count value: '4398046510080' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 +4294967295 SET @@global.max_prepared_stmt_count = ON; ERROR 42000: Incorrect argument type to variable 'max_prepared_stmt_count' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 +4294967295 SET @@global.max_prepared_stmt_count = 'test'; ERROR 42000: Incorrect argument type to variable 'max_prepared_stmt_count' SELECT @@global.max_prepared_stmt_count; @@global.max_prepared_stmt_count -1048576 +4294967295 '#-------------------FN_DYNVARS_081_05----------------------------#' SET @@session.max_prepared_stmt_count = 4096; ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff index a57fc12948c68892e71aeb4616e1627aaee7834d..65439e3ae5a51cd7497a6f56a7286e79db8ba0f9 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff @@ -298,7 +298,7 @@ VARIABLE_NAME INNODB_DATA_FILE_PATH SESSION_VALUE NULL GLOBAL_VALUE ibdata1:12M:autoextend -@@ -767,7 +907,7 @@ +@@ -781,7 +921,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 120 VARIABLE_SCOPE GLOBAL @@ -307,7 +307,7 @@ VARIABLE_COMMENT Number of pages reserved in doublewrite buffer for batch flushing NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 127 -@@ -775,6 +915,20 @@ +@@ -789,6 +929,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL @@ -328,7 +328,7 @@ VARIABLE_NAME INNODB_ENCRYPTION_ROTATE_KEY_AGE SESSION_VALUE NULL GLOBAL_VALUE 1 -@@ -845,13 +999,27 @@ +@@ -859,13 +1013,27 @@ ENUM_VALUE_LIST OFF,ON,FORCE READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -357,7 +357,7 @@ VARIABLE_COMMENT Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like). NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -865,7 +1033,7 @@ +@@ -879,7 +1047,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 600 VARIABLE_SCOPE GLOBAL @@ -366,7 +366,7 @@ VARIABLE_COMMENT Maximum number of seconds that semaphore times out in InnoDB. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -935,7 +1103,7 @@ +@@ -949,7 +1117,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -375,7 +375,7 @@ VARIABLE_COMMENT Make the first page of the given tablespace dirty. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -949,7 +1117,7 @@ +@@ -963,7 +1131,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL @@ -384,7 +384,7 @@ VARIABLE_COMMENT Number of iterations over which the background flushing is averaged. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1000 -@@ -972,12 +1140,12 @@ +@@ -986,12 +1154,12 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FLUSH_LOG_AT_TRX_COMMIT @@ -400,7 +400,7 @@ VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 3 -@@ -1005,7 +1173,7 @@ +@@ -1019,7 +1187,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -409,7 +409,7 @@ VARIABLE_COMMENT Set to 0 (don't flush neighbors from buffer pool), 1 (flush contiguous neighbors from buffer pool) or 2 (flush neighbors from buffer pool), when flushing a block NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -1047,7 +1215,7 @@ +@@ -1061,7 +1229,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -418,7 +418,7 @@ VARIABLE_COMMENT Helps to save your data in case the disk image of the database becomes corrupt. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 6 -@@ -1055,6 +1223,20 @@ +@@ -1069,6 +1237,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED @@ -439,7 +439,7 @@ VARIABLE_NAME INNODB_FT_AUX_TABLE SESSION_VALUE NULL GLOBAL_VALUE -@@ -1075,7 +1257,7 @@ +@@ -1089,7 +1271,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8000000 VARIABLE_SCOPE GLOBAL @@ -448,7 +448,7 @@ VARIABLE_COMMENT InnoDB Fulltext search cache size in bytes NUMERIC_MIN_VALUE 1600000 NUMERIC_MAX_VALUE 80000000 -@@ -1117,7 +1299,7 @@ +@@ -1131,7 +1313,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 84 VARIABLE_SCOPE GLOBAL @@ -457,7 +457,7 @@ VARIABLE_COMMENT InnoDB Fulltext search maximum token size in characters NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 84 -@@ -1131,7 +1313,7 @@ +@@ -1145,7 +1327,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 3 VARIABLE_SCOPE GLOBAL @@ -466,7 +466,7 @@ VARIABLE_COMMENT InnoDB Fulltext search minimum token size in characters NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16 -@@ -1145,7 +1327,7 @@ +@@ -1159,7 +1341,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 2000 VARIABLE_SCOPE GLOBAL @@ -475,7 +475,7 @@ VARIABLE_COMMENT InnoDB Fulltext search number of words to optimize for each optimize table call NUMERIC_MIN_VALUE 1000 NUMERIC_MAX_VALUE 10000 -@@ -1159,7 +1341,7 @@ +@@ -1173,7 +1355,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 2000000000 VARIABLE_SCOPE GLOBAL @@ -484,7 +484,7 @@ VARIABLE_COMMENT InnoDB Fulltext search query result cache limit in bytes NUMERIC_MIN_VALUE 1000000 NUMERIC_MAX_VALUE 4294967295 -@@ -1187,7 +1369,7 @@ +@@ -1201,7 +1383,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 2 VARIABLE_SCOPE GLOBAL @@ -493,7 +493,7 @@ VARIABLE_COMMENT InnoDB Fulltext search parallel sort degree, will round up to nearest power of 2 number NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 16 -@@ -1201,7 +1383,7 @@ +@@ -1215,7 +1397,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 640000000 VARIABLE_SCOPE GLOBAL @@ -502,7 +502,7 @@ VARIABLE_COMMENT Total memory allocated for InnoDB Fulltext Search cache NUMERIC_MIN_VALUE 32000000 NUMERIC_MAX_VALUE 1600000000 -@@ -1229,7 +1411,7 @@ +@@ -1243,7 +1425,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 100 VARIABLE_SCOPE GLOBAL @@ -511,7 +511,7 @@ VARIABLE_COMMENT Up to what percentage of dirty pages should be flushed when innodb finds it has spare resources to do so. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -1271,10 +1453,10 @@ +@@ -1285,10 +1467,10 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 200 VARIABLE_SCOPE GLOBAL @@ -524,7 +524,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1283,12 +1465,26 @@ +@@ -1297,12 +1479,26 @@ SESSION_VALUE NULL GLOBAL_VALUE 2000 GLOBAL_VALUE_ORIGIN COMPILE-TIME @@ -554,7 +554,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1321,6 +1517,20 @@ +@@ -1335,6 +1531,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -575,7 +575,7 @@ VARIABLE_NAME INNODB_LOCKS_UNSAFE_FOR_BINLOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1355,7 +1565,7 @@ +@@ -1369,7 +1579,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 50 VARIABLE_SCOPE SESSION @@ -584,44 +584,26 @@ VARIABLE_COMMENT Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1073741824 -@@ -1363,37 +1573,107 @@ +@@ -1377,16 +1587,72 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED --VARIABLE_NAME INNODB_LOG_BUFFER_SIZE --SESSION_VALUE NULL --GLOBAL_VALUE 1048576 --GLOBAL_VALUE_ORIGIN CONFIG --DEFAULT_VALUE 16777216 --VARIABLE_SCOPE GLOBAL --VARIABLE_TYPE BIGINT --VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk. --NUMERIC_MIN_VALUE 262144 --NUMERIC_MAX_VALUE 9223372036854775807 --NUMERIC_BLOCK_SIZE 1024 --ENUM_VALUE_LIST NULL --READ_ONLY YES --COMMAND_LINE_ARGUMENT REQUIRED --VARIABLE_NAME INNODB_LOG_CHECKPOINT_NOW +VARIABLE_NAME INNODB_LOG_ARCHIVE - SESSION_VALUE NULL - GLOBAL_VALUE OFF - GLOBAL_VALUE_ORIGIN COMPILE-TIME - DEFAULT_VALUE OFF - VARIABLE_SCOPE GLOBAL - VARIABLE_TYPE BOOLEAN --VARIABLE_COMMENT Force checkpoint now ++SESSION_VALUE NULL ++GLOBAL_VALUE OFF ++GLOBAL_VALUE_ORIGIN COMPILE-TIME ++DEFAULT_VALUE OFF ++VARIABLE_SCOPE GLOBAL ++VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Set to 1 if you want to have logs archived. - NUMERIC_MIN_VALUE NULL - NUMERIC_MAX_VALUE NULL - NUMERIC_BLOCK_SIZE NULL - ENUM_VALUE_LIST OFF,ON - READ_ONLY NO - COMMAND_LINE_ARGUMENT OPTIONAL --VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES ++NUMERIC_MIN_VALUE NULL ++NUMERIC_MAX_VALUE NULL ++NUMERIC_BLOCK_SIZE NULL ++ENUM_VALUE_LIST OFF,ON ++READ_ONLY NO ++COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_LOG_ARCH_DIR - SESSION_VALUE NULL --GLOBAL_VALUE ON ++SESSION_VALUE NULL +GLOBAL_VALUE PATH +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE @@ -662,34 +644,25 @@ +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT REQUIRED -+VARIABLE_NAME INNODB_LOG_BUFFER_SIZE -+SESSION_VALUE NULL -+GLOBAL_VALUE 1048576 -+GLOBAL_VALUE_ORIGIN CONFIG -+DEFAULT_VALUE 16777216 -+VARIABLE_SCOPE GLOBAL + VARIABLE_NAME INNODB_LOG_BUFFER_SIZE + SESSION_VALUE NULL + GLOBAL_VALUE 1048576 + GLOBAL_VALUE_ORIGIN CONFIG + DEFAULT_VALUE 16777216 + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT +VARIABLE_TYPE INT -+VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk. -+NUMERIC_MIN_VALUE 262144 + VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk. + NUMERIC_MIN_VALUE 262144 +-NUMERIC_MAX_VALUE 9223372036854775807 +NUMERIC_MAX_VALUE 2147483647 -+NUMERIC_BLOCK_SIZE 1024 -+ENUM_VALUE_LIST NULL -+READ_ONLY YES -+COMMAND_LINE_ARGUMENT REQUIRED -+VARIABLE_NAME INNODB_LOG_CHECKPOINT_NOW -+SESSION_VALUE NULL -+GLOBAL_VALUE OFF -+GLOBAL_VALUE_ORIGIN COMPILE-TIME -+DEFAULT_VALUE OFF -+VARIABLE_SCOPE GLOBAL -+VARIABLE_TYPE BOOLEAN -+VARIABLE_COMMENT Force checkpoint now -+NUMERIC_MIN_VALUE NULL -+NUMERIC_MAX_VALUE NULL -+NUMERIC_BLOCK_SIZE NULL -+ENUM_VALUE_LIST OFF,ON -+READ_ONLY NO -+COMMAND_LINE_ARGUMENT OPTIONAL + NUMERIC_BLOCK_SIZE 1024 + ENUM_VALUE_LIST NULL + READ_ONLY YES +@@ -1405,6 +1671,20 @@ + ENUM_VALUE_LIST OFF,ON + READ_ONLY NO + COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME INNODB_LOG_CHECKSUM_ALGORITHM +SESSION_VALUE NULL +GLOBAL_VALUE INNODB @@ -704,13 +677,10 @@ +ENUM_VALUE_LIST CRC32,STRICT_CRC32,INNODB,STRICT_INNODB,NONE,STRICT_NONE +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED -+VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES -+SESSION_VALUE NULL -+GLOBAL_VALUE ON - GLOBAL_VALUE_ORIGIN COMPILE-TIME - DEFAULT_VALUE ON - VARIABLE_SCOPE GLOBAL -@@ -1411,7 +1691,7 @@ + VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES + SESSION_VALUE NULL + GLOBAL_VALUE ON +@@ -1425,7 +1705,7 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 2 VARIABLE_SCOPE GLOBAL @@ -719,7 +689,7 @@ VARIABLE_COMMENT Number of log files in the log group. InnoDB writes to the files in a circular fashion. NUMERIC_MIN_VALUE 2 NUMERIC_MAX_VALUE 100 -@@ -1453,9 +1733,37 @@ +@@ -1467,9 +1747,37 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 1024 VARIABLE_SCOPE GLOBAL @@ -758,7 +728,7 @@ NUMERIC_MAX_VALUE 18446744073709551615 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL -@@ -1495,10 +1803,10 @@ +@@ -1509,10 +1817,10 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -771,7 +741,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1509,7 +1817,7 @@ +@@ -1523,7 +1831,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -780,7 +750,7 @@ VARIABLE_COMMENT Maximum delay of user threads in micro-seconds NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 10000000 -@@ -1523,7 +1831,7 @@ +@@ -1537,7 +1845,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -789,7 +759,7 @@ VARIABLE_COMMENT Number of identical copies of log groups we keep for the database. Currently this should be set to 1. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 10 -@@ -1593,7 +1901,7 @@ +@@ -1607,7 +1915,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL @@ -798,7 +768,12 @@ VARIABLE_COMMENT Number of multi-threaded flush threads NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 -@@ -1649,10 +1957,10 @@ +@@ -1659,14 +1967,14 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME INNODB_OPEN_FILES + SESSION_VALUE NULL +-GLOBAL_VALUE 2000 ++GLOBAL_VALUE 300 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -811,7 +786,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -1677,7 +1985,7 @@ +@@ -1691,7 +1999,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 16 VARIABLE_SCOPE GLOBAL @@ -820,7 +795,7 @@ VARIABLE_COMMENT Number of rw_locks protecting buffer pool page_hash. Rounded up to the next power of 2 NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1024 -@@ -1691,7 +1999,7 @@ +@@ -1705,7 +2013,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 16384 VARIABLE_SCOPE GLOBAL @@ -829,7 +804,7 @@ VARIABLE_COMMENT Page size to use for all InnoDB tablespaces. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 65536 -@@ -1727,13 +2035,83 @@ +@@ -1741,13 +2049,83 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -914,7 +889,7 @@ VARIABLE_COMMENT Number of UNDO log pages to purge in one batch from the history list. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5000 -@@ -1775,7 +2139,7 @@ +@@ -1789,7 +2167,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -923,7 +898,7 @@ VARIABLE_COMMENT Purge threads can be from 1 to 32. Default is 1. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 32 -@@ -1803,7 +2167,7 @@ +@@ -1817,7 +2195,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 56 VARIABLE_SCOPE GLOBAL @@ -932,7 +907,7 @@ VARIABLE_COMMENT Number of pages that must be accessed sequentially for InnoDB to trigger a readahead. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 64 -@@ -1817,7 +2181,7 @@ +@@ -1831,7 +2209,7 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 4 VARIABLE_SCOPE GLOBAL @@ -941,7 +916,7 @@ VARIABLE_COMMENT Number of background read I/O threads in InnoDB. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 -@@ -1845,10 +2209,10 @@ +@@ -1859,10 +2237,10 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -954,7 +929,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1873,7 +2237,7 @@ +@@ -1887,7 +2265,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 128 VARIABLE_SCOPE GLOBAL @@ -963,7 +938,7 @@ VARIABLE_COMMENT Number of undo logs to use (deprecated). NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -1887,7 +2251,7 @@ +@@ -1901,7 +2279,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -972,7 +947,7 @@ VARIABLE_COMMENT An InnoDB page number. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -1895,6 +2259,48 @@ +@@ -1909,6 +2287,48 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -1021,7 +996,7 @@ VARIABLE_NAME INNODB_SCRUB_LOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1923,6 +2329,34 @@ +@@ -1937,6 +2357,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -1056,7 +1031,7 @@ VARIABLE_NAME INNODB_SIMULATE_COMP_FAILURES SESSION_VALUE NULL GLOBAL_VALUE 0 -@@ -1943,7 +2377,7 @@ +@@ -1957,7 +2405,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 1048576 VARIABLE_SCOPE GLOBAL @@ -1065,7 +1040,7 @@ VARIABLE_COMMENT Memory buffer size for index creation NUMERIC_MIN_VALUE 65536 NUMERIC_MAX_VALUE 67108864 -@@ -1957,10 +2391,10 @@ +@@ -1971,10 +2419,10 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 6 VARIABLE_SCOPE GLOBAL @@ -1078,7 +1053,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2000,7 +2434,7 @@ +@@ -2014,7 +2462,7 @@ DEFAULT_VALUE nulls_equal VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM @@ -1087,7 +1062,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2167,7 +2601,7 @@ +@@ -2181,7 +2629,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -1096,7 +1071,7 @@ VARIABLE_COMMENT Size of the mutex/lock wait array. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1024 -@@ -2181,10 +2615,10 @@ +@@ -2195,10 +2643,10 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL @@ -1109,7 +1084,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -2209,7 +2643,7 @@ +@@ -2223,7 +2671,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -1118,7 +1093,7 @@ VARIABLE_COMMENT Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1000 -@@ -2223,7 +2657,7 @@ +@@ -2237,7 +2685,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 10000 VARIABLE_SCOPE GLOBAL @@ -1127,7 +1102,7 @@ VARIABLE_COMMENT Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1000000 -@@ -2245,6 +2679,34 @@ +@@ -2259,6 +2707,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -1162,7 +1137,7 @@ VARIABLE_NAME INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2293,7 +2755,7 @@ +@@ -2307,7 +2783,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 128 VARIABLE_SCOPE GLOBAL @@ -1171,7 +1146,7 @@ VARIABLE_COMMENT Number of undo logs to use. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -2307,7 +2769,7 @@ +@@ -2321,7 +2797,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -1180,7 +1155,7 @@ VARIABLE_COMMENT Number of undo tablespaces to use. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 126 -@@ -2322,7 +2784,7 @@ +@@ -2336,7 +2812,7 @@ DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN @@ -1189,7 +1164,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2343,6 +2805,20 @@ +@@ -2357,6 +2833,20 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -1210,7 +1185,7 @@ VARIABLE_NAME INNODB_USE_MTFLUSH SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2357,6 +2833,20 @@ +@@ -2371,6 +2861,20 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -1231,12 +1206,12 @@ VARIABLE_NAME INNODB_USE_SYS_MALLOC SESSION_VALUE NULL GLOBAL_VALUE ON -@@ -2387,12 +2877,12 @@ +@@ -2401,12 +2905,12 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.37 -+GLOBAL_VALUE 5.6.36-83.0 +-GLOBAL_VALUE 5.6.40 ++GLOBAL_VALUE 5.6.39-83.1 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL @@ -1246,7 +1221,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2405,7 +2895,7 @@ +@@ -2419,7 +2923,7 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 4 VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff index 0a2757c5138675b139c257bce55b4299dbfd268d..dafdde75e125bdeedac6fdbac22d59e6b0cc33ed 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff @@ -177,7 +177,7 @@ VARIABLE_NAME INNODB_DATA_FILE_PATH SESSION_VALUE NULL GLOBAL_VALUE ibdata1:12M:autoextend -@@ -775,6 +915,20 @@ +@@ -789,6 +929,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL @@ -198,7 +198,7 @@ VARIABLE_NAME INNODB_ENCRYPTION_ROTATE_KEY_AGE SESSION_VALUE NULL GLOBAL_VALUE 1 -@@ -845,6 +999,20 @@ +@@ -859,6 +1013,20 @@ ENUM_VALUE_LIST OFF,ON,FORCE READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -219,7 +219,7 @@ VARIABLE_NAME INNODB_FAST_SHUTDOWN SESSION_VALUE NULL GLOBAL_VALUE 1 -@@ -972,11 +1140,11 @@ +@@ -986,11 +1154,11 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_FLUSH_LOG_AT_TRX_COMMIT @@ -233,7 +233,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3. NUMERIC_MIN_VALUE 0 -@@ -1055,6 +1223,20 @@ +@@ -1069,6 +1237,20 @@ ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED @@ -254,7 +254,7 @@ VARIABLE_NAME INNODB_FT_AUX_TABLE SESSION_VALUE NULL GLOBAL_VALUE -@@ -1293,6 +1475,20 @@ +@@ -1307,6 +1489,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -275,7 +275,7 @@ VARIABLE_NAME INNODB_LARGE_PREFIX SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1321,6 +1517,20 @@ +@@ -1335,6 +1531,20 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -296,7 +296,7 @@ VARIABLE_NAME INNODB_LOCKS_UNSAFE_FOR_BINLOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1363,6 +1573,62 @@ +@@ -1377,6 +1587,62 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -359,7 +359,7 @@ VARIABLE_NAME INNODB_LOG_BUFFER_SIZE SESSION_VALUE NULL GLOBAL_VALUE 1048576 -@@ -1391,6 +1657,20 @@ +@@ -1405,6 +1671,20 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -380,7 +380,7 @@ VARIABLE_NAME INNODB_LOG_COMPRESSED_PAGES SESSION_VALUE NULL GLOBAL_VALUE ON -@@ -1461,6 +1741,34 @@ +@@ -1475,6 +1755,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED @@ -415,7 +415,16 @@ VARIABLE_NAME INNODB_MAX_DIRTY_PAGES_PCT SESSION_VALUE NULL GLOBAL_VALUE 75.000000 -@@ -1727,6 +2035,76 @@ +@@ -1659,7 +1967,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME INNODB_OPEN_FILES + SESSION_VALUE NULL +-GLOBAL_VALUE 2000 ++GLOBAL_VALUE 300 + GLOBAL_VALUE_ORIGIN COMPILE-TIME + DEFAULT_VALUE 0 + VARIABLE_SCOPE GLOBAL +@@ -1741,6 +2049,76 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -492,7 +501,7 @@ VARIABLE_NAME INNODB_PURGE_BATCH_SIZE SESSION_VALUE NULL GLOBAL_VALUE 300 -@@ -1895,6 +2273,48 @@ +@@ -1909,6 +2287,48 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -541,7 +550,7 @@ VARIABLE_NAME INNODB_SCRUB_LOG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -1923,6 +2343,34 @@ +@@ -1937,6 +2357,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -576,7 +585,7 @@ VARIABLE_NAME INNODB_SIMULATE_COMP_FAILURES SESSION_VALUE NULL GLOBAL_VALUE 0 -@@ -2000,7 +2448,7 @@ +@@ -2014,7 +2462,7 @@ DEFAULT_VALUE nulls_equal VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM @@ -585,7 +594,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2245,6 +2693,34 @@ +@@ -2259,6 +2707,34 @@ ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL @@ -620,7 +629,7 @@ VARIABLE_NAME INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2322,7 +2798,7 @@ +@@ -2336,7 +2812,7 @@ DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN @@ -629,7 +638,7 @@ NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -@@ -2343,6 +2819,20 @@ +@@ -2357,6 +2833,20 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -650,7 +659,7 @@ VARIABLE_NAME INNODB_USE_MTFLUSH SESSION_VALUE NULL GLOBAL_VALUE OFF -@@ -2357,6 +2847,20 @@ +@@ -2371,6 +2861,20 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT NONE @@ -671,12 +680,12 @@ VARIABLE_NAME INNODB_USE_SYS_MALLOC SESSION_VALUE NULL GLOBAL_VALUE ON -@@ -2387,12 +2891,12 @@ +@@ -2401,12 +2905,12 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.37 -+GLOBAL_VALUE 5.6.36-83.0 +-GLOBAL_VALUE 5.6.40 ++GLOBAL_VALUE 5.6.39-83.1 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 161f740dbfb9e3a945da2d77f43b78134ca361ec..05bb199acbf8d1a5b2183227fada8ca026219d91 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -635,6 +635,20 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_DEFAULT_ROW_FORMAT +SESSION_VALUE NULL +GLOBAL_VALUE compact +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE compact +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE ENUM +VARIABLE_COMMENT The default ROW FORMAT for all innodb tables created without explicit ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC. The ROW_FORMAT value COMPRESSED is not allowed +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST redundant,compact,dynamic +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_DEFRAGMENT SESSION_VALUE NULL GLOBAL_VALUE OFF @@ -2387,7 +2401,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.37 +GLOBAL_VALUE 5.6.40 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index f851dfcc5a474e27bd1558916ba06f831105b5ba..7f046a188cc13c4d162cb5fb622a4f903ec1977d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1837,7 +1837,7 @@ DEFAULT_VALUE 151 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The number of simultaneous clients allowed -NUMERIC_MIN_VALUE 1 +NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 100000 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL @@ -1975,10 +1975,10 @@ GLOBAL_VALUE 16382 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 16382 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Maximum number of prepared statements in the server NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 1048576 +NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO @@ -3847,13 +3847,13 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE SESSION_VALUE NULL -GLOBAL_VALUE 2000 -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE 100 +GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 2000 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The number of cached open tables -NUMERIC_MIN_VALUE 1 +NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 5bc6a6e1743197e84e78cc41497dc5a3bb41d26c..72550ffb3affb9d5a876ccadd3d15e0063354562 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -2019,7 +2019,7 @@ DEFAULT_VALUE 151 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The number of simultaneous clients allowed -NUMERIC_MIN_VALUE 1 +NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 100000 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL @@ -2157,10 +2157,10 @@ GLOBAL_VALUE 16382 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 16382 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Maximum number of prepared statements in the server NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 1048576 +NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO @@ -4547,13 +4547,13 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE SESSION_VALUE NULL -GLOBAL_VALUE 2000 -GLOBAL_VALUE_ORIGIN COMPILE-TIME +GLOBAL_VALUE 100 +GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 2000 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The number of cached open tables -NUMERIC_MIN_VALUE 1 +NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 0c206975c294ced7ba91b4c87bbd01d51ee3537e..db932ae8223fd6b0fbefb2965c2ebf09dacabb53 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -421,6 +421,20 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME WSREP_REJECT_QUERIES +SESSION_VALUE NULL +GLOBAL_VALUE NONE +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE NONE +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Variable to set to reject queries +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NONE,ALL,ALL_KILL +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME WSREP_REPLICATE_MYISAM SESSION_VALUE NULL GLOBAL_VALUE OFF diff --git a/mysql-test/suite/sys_vars/r/table_open_cache_basic.result b/mysql-test/suite/sys_vars/r/table_open_cache_basic.result index 4c63578375390afa4a8d2dc21f32cb1799d211e7..bc373003e1d7d91f8a5e1c185c89e7a5e6332dc0 100644 --- a/mysql-test/suite/sys_vars/r/table_open_cache_basic.result +++ b/mysql-test/suite/sys_vars/r/table_open_cache_basic.result @@ -1,7 +1,7 @@ SET @start_value = @@global.table_open_cache ; SELECT @start_value; @start_value -2000 +421 '#--------------------FN_DYNVARS_001_01------------------------#' SET @@global.table_open_cache = 99; SET @@global.table_open_cache = DeFAULT; @@ -15,13 +15,17 @@ SELECT @@global.table_open_cache = 400; 0 '#--------------------FN_DYNVARS_001_03------------------------#' SET @@global.table_open_cache = 8; +Warnings: +Warning 1292 Truncated incorrect table_open_cache value: '8' SELECT @@global.table_open_cache ; @@global.table_open_cache -8 +10 SET @@global.table_open_cache = 1; +Warnings: +Warning 1292 Truncated incorrect table_open_cache value: '1' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 SET @@global.table_open_cache = 1073741824; Warnings: Warning 1292 Truncated incorrect table_open_cache value: '1073741824' @@ -42,7 +46,7 @@ Warnings: Warning 1292 Truncated incorrect table_open_cache value: '-1' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 SET @@global.table_open_cache = 100000000000; Warnings: Warning 1292 Truncated incorrect table_open_cache value: '100000000000' @@ -54,13 +58,13 @@ Warnings: Warning 1292 Truncated incorrect table_open_cache value: '-1024' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 SET @@global.table_open_cache = 0; Warnings: Warning 1292 Truncated incorrect table_open_cache value: '0' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 SET @@global.table_open_cache = 10000.01; ERROR 42000: Incorrect argument type to variable 'table_open_cache' SET @@global.table_open_cache = ON; @@ -78,15 +82,17 @@ SELECT @@global.table_open_cache = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL 1 '#---------------------FN_DYNVARS_001_09----------------------#' SET @@global.table_open_cache = TRUE; +Warnings: +Warning 1292 Truncated incorrect table_open_cache value: '1' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 SET @@global.table_open_cache = FALSE; Warnings: Warning 1292 Truncated incorrect table_open_cache value: '0' SELECT @@global.table_open_cache ; @@global.table_open_cache -1 +10 '#---------------------FN_DYNVARS_001_10----------------------#' SET @@global.table_open_cache = 10; SELECT @@table_open_cache = @@global.table_open_cache ; @@ -104,4 +110,4 @@ ERROR 42S22: Unknown column 'table_open_cache' in 'field list' SET @@global.table_open_cache = @start_value; SELECT @@global.table_open_cache ; @@global.table_open_cache -2000 +421 diff --git a/mysql-test/suite/sys_vars/r/wsrep_sst_receive_address_basic.result b/mysql-test/suite/sys_vars/r/wsrep_sst_receive_address_basic.result index 6db52eb815036d2547ec732db6808d956f5e3f18..3e1fb6cad79deb022989a44671483f8e857fefe7 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_sst_receive_address_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_sst_receive_address_basic.result @@ -30,10 +30,6 @@ SELECT @@global.wsrep_sst_receive_address; 192.168.2.254 # invalid values -SET @@global.wsrep_sst_receive_address='127.0.0.1:4444'; -ERROR 42000: Variable 'wsrep_sst_receive_address' can't be set to the value of '127.0.0.1:4444' -SET @@global.wsrep_sst_receive_address='127.0.0.1'; -ERROR 42000: Variable 'wsrep_sst_receive_address' can't be set to the value of '127.0.0.1' SELECT @@global.wsrep_sst_receive_address; @@global.wsrep_sst_receive_address 192.168.2.254 diff --git a/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test b/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test new file mode 100644 index 0000000000000000000000000000000000000000..f9aabf49ba4d37028320001da408b1c2556e3181 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_default_row_format_basic.test @@ -0,0 +1,41 @@ +--source include/have_innodb.inc + +# Check the default value +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'redundant'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'dynamic'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 'compact'; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 'compressed'; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 'foobar'; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 0; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 1; +SELECT @@global.innodb_default_row_format; + +SET GLOBAL innodb_default_row_format = 2; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 3; +SELECT @@global.innodb_default_row_format; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_row_format = 123; +SELECT @@global.innodb_default_row_format; + + +SET GLOBAL innodb_default_row_format = default; diff --git a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_basic.test b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_basic.test index 5bf5d9c8834f17306d3bd8bab70ca5fa892a751e..a97256d84a47d6c66244a3d355afef681af256fb 100644 --- a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_basic.test +++ b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_basic.test @@ -92,9 +92,9 @@ SET @@global.max_prepared_stmt_count = 10000.01; SELECT @@global.max_prepared_stmt_count; SET @@global.max_prepared_stmt_count = -1024; SELECT @@global.max_prepared_stmt_count; -SET @@global.max_prepared_stmt_count = 1048577; +SET @@global.max_prepared_stmt_count = 4294967296; SELECT @@global.max_prepared_stmt_count; -SET @@global.max_prepared_stmt_count = 104857612; +SET @@global.max_prepared_stmt_count = 4294967295*1024; SELECT @@global.max_prepared_stmt_count; --Error ER_WRONG_TYPE_FOR_VAR diff --git a/mysql-test/suite/sys_vars/t/sysvars_innodb.opt b/mysql-test/suite/sys_vars/t/sysvars_innodb.opt index 462e83d98b6476535fa433bbd64e003e859ce1ec..c3eec59bc17fe6d9577dc840db1068267c400966 100644 --- a/mysql-test/suite/sys_vars/t/sysvars_innodb.opt +++ b/mysql-test/suite/sys_vars/t/sysvars_innodb.opt @@ -1 +1,2 @@ --loose-innodb-flush-log-at-timeout=3 +--table_open_cache=200 diff --git a/mysql-test/suite/sys_vars/t/sysvars_server_embedded.opt b/mysql-test/suite/sys_vars/t/sysvars_server_embedded.opt new file mode 100644 index 0000000000000000000000000000000000000000..c3f0d3bd51fec1049132e5175359888bb7046259 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/sysvars_server_embedded.opt @@ -0,0 +1 @@ +--table_open_cache=100 diff --git a/mysql-test/suite/sys_vars/t/sysvars_server_notembedded.opt b/mysql-test/suite/sys_vars/t/sysvars_server_notembedded.opt new file mode 100644 index 0000000000000000000000000000000000000000..c3f0d3bd51fec1049132e5175359888bb7046259 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/sysvars_server_notembedded.opt @@ -0,0 +1 @@ +--table_open_cache=100 diff --git a/mysql-test/suite/sys_vars/t/wsrep_sst_receive_address_basic.test b/mysql-test/suite/sys_vars/t/wsrep_sst_receive_address_basic.test index 9e50cbf8947227ab25e7379d06d3e47a19d43ae4..59f69c14dfb87b705f7ffadd3bb28061a09ded83 100644 --- a/mysql-test/suite/sys_vars/t/wsrep_sst_receive_address_basic.test +++ b/mysql-test/suite/sys_vars/t/wsrep_sst_receive_address_basic.test @@ -27,10 +27,6 @@ SELECT @@global.wsrep_sst_receive_address; --echo --echo # invalid values ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.wsrep_sst_receive_address='127.0.0.1:4444'; ---error ER_WRONG_VALUE_FOR_VAR -SET @@global.wsrep_sst_receive_address='127.0.0.1'; SELECT @@global.wsrep_sst_receive_address; --error ER_WRONG_VALUE_FOR_VAR SET @@global.wsrep_sst_receive_address=NULL; diff --git a/mysql-test/suite/unit/suite.pm b/mysql-test/suite/unit/suite.pm index 966fd278a52641a8d10adad54104039b6e309670..fa1da2ae4ff8ba0102d0fbdd5fa3bbd1f4dc47d6 100644 --- a/mysql-test/suite/unit/suite.pm +++ b/mysql-test/suite/unit/suite.pm @@ -40,7 +40,7 @@ sub start_test { return "Not run for embedded server" if $::opt_embedded_server; return "Not configured to run ctest" unless -f "../CTestTestfile.cmake"; my ($ctest_vs)= $opt_vs_config ? "--build-config $opt_vs_config" : ""; - my (@ctest_list)= `cd .. && ctest $opt_vs_config --show-only --verbose`; + my (@ctest_list)= `cd .. && ctest $opt_vs_config -E MTR -C default_ignore --show-only --verbose`; return "No ctest" if $?; my ($command, %tests); diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result index 62d7f62440fb861bfd1a611b8854feb1a6ddd871..4ecc1ca3b79fe685e8f647dd0adf893de1eb3f47 100644 --- a/mysql-test/suite/wsrep/r/variables.result +++ b/mysql-test/suite/wsrep/r/variables.result @@ -207,6 +207,13 @@ Threads_connected 1 SHOW STATUS LIKE 'wsrep_thread_count'; Variable_name Value wsrep_thread_count 11 +set wsrep_on=0; +set wsrep_on=1; +create user test@localhost; +set auto_increment_increment=10; +set wsrep_on=0; +ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation +drop user test@localhost; # # MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash # diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test index 1769f56784879601ece06d821f106df5e2054e0e..1315f090d5c3267856acb7ca35201e8728b97a76 100644 --- a/mysql-test/suite/wsrep/t/variables.test +++ b/mysql-test/suite/wsrep/t/variables.test @@ -118,6 +118,20 @@ sleep 3; SHOW STATUS LIKE 'threads_connected'; SHOW STATUS LIKE 'wsrep_thread_count'; +# +# privileges for wsrep_on +# +set wsrep_on=0; +set wsrep_on=1; +create user test@localhost; +connect con1,localhost,test; +set auto_increment_increment=10; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +set wsrep_on=0; +disconnect con1; +connection default; +drop user test@localhost; + --echo # --echo # MDEV#6411: Setting set @@global.wsrep_sst_auth=NULL causes crash --echo # diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 5cb33516ed2f1e5a8b3059a7be58050aca9892d0..420f733afdf4b68f08428d839317bbe9256fd3c1 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1809,6 +1809,52 @@ ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; SHOW CREATE TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-15308 +--echo # Assertion `ha_alter_info->alter_info->drop_list.elements > 0' failed +--echo # in ha_innodb::prepare_inplace_alter_table +--echo # + +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN b; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN b; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b INT, c INT, KEY(c)) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN c; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b INT, c INT, KEY c1(c)) ENGINE=InnoDB; +ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP INDEX c1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN IF EXISTS c; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-14668 ADD PRIMARY KEY IF NOT EXISTS on composite key +--echo # +CREATE TABLE t1 ( + `ID` BIGINT(20) NOT NULL, + `RANK` MEDIUMINT(4) NOT NULL, + `CHECK_POINT` BIGINT(20) NOT NULL, + UNIQUE INDEX `HORIZON_UIDX01` (`ID`, `RANK`) + ) ENGINE=InnoDB; + +ALTER TABLE t1 ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); +DROP TABLE t1; + --echo # --echo # End of 10.0 tests --echo # diff --git a/mysql-test/t/assign_key_cache.test b/mysql-test/t/assign_key_cache.test new file mode 100644 index 0000000000000000000000000000000000000000..401e7bf9138e42a27a035f87361899cd427f8e29 --- /dev/null +++ b/mysql-test/t/assign_key_cache.test @@ -0,0 +1,13 @@ +# +# MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA +# +--source include/have_partition.inc +set global my_cache.key_buffer_size = 1024*1024; +create table t1 (i int) engine=myisam partition by hash (i) partitions 2; +xa start 'xid'; +cache index t1 partition (non_existing_partition) in my_cache; +cache index t1 partition (p1) in my_cache; +xa end 'xid'; +xa rollback 'xid'; +drop table t1; +set global my_cache.key_buffer_size = 0; diff --git a/mysql-test/t/assign_key_cache-5405.test b/mysql-test/t/assign_key_cache_debug.test similarity index 100% rename from mysql-test/t/assign_key_cache-5405.test rename to mysql-test/t/assign_key_cache_debug.test diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 20989e70ef9e8e64dcee5a67cbc1aa678ef3b298..c2d44c08e222b97fa293607c220f2ccadf32dffc 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -143,9 +143,18 @@ GRANT USAGE ON *.* TO mysqltest_u1@localhost; --echo let $saved_max_connections = `SELECT @@global.max_connections`; -SET GLOBAL max_connections = 3; +SET GLOBAL max_connections = 10; SET GLOBAL event_scheduler = ON; +connect (tmp_con1,localhost,mysqltest_u1,,); +connect (tmp_con2,localhost,mysqltest_u1,,); +connect (tmp_con3,localhost,mysqltest_u1,,); +connect (tmp_con4,localhost,mysqltest_u1,,); +connect (tmp_con5,localhost,mysqltest_u1,,); +connect (tmp_con6,localhost,mysqltest_u1,,); +connect (tmp_con7,localhost,mysqltest_u1,,); +connection default; + --echo --echo # -- Waiting for Event Scheduler to start... let $wait_condition = @@ -230,6 +239,13 @@ let $wait_condition = --disconnect con_2 --disconnect con_3 --disconnect con_super_1 +--disconnect tmp_con1 +--disconnect tmp_con2 +--disconnect tmp_con3 +--disconnect tmp_con4 +--disconnect tmp_con5 +--disconnect tmp_con6 +--disconnect tmp_con7 --echo --echo # -- Restoring default connection... diff --git a/mysql-test/t/connect_debug.test b/mysql-test/t/connect_debug.test new file mode 100644 index 0000000000000000000000000000000000000000..299b605b2cd081884532443115755bc561547da7 --- /dev/null +++ b/mysql-test/t/connect_debug.test @@ -0,0 +1,12 @@ +source include/have_debug.inc; +set @old_dbug=@@global.debug_dbug; + +# +# use after free if need plugin change and auth aborted +# +set global debug_dbug='+d,auth_disconnect'; +create user 'bad' identified by 'worse'; +--error 1 +--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse +set global debug_dbug=@old_dbug; +drop user bad; diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test index abf470b62d5ef9fdb90ff9c86492e3e97c8854eb..c1441d218cfb8cca2178ef7b6af1ee10a026063c 100644 --- a/mysql-test/t/create_or_replace.test +++ b/mysql-test/t/create_or_replace.test @@ -396,3 +396,28 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1(); UNLOCK TABLES; DROP FUNCTION f1; DROP TABLE t1; + +--echo # +--echo # MDEV-11129 +--echo # CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() +--echo # references t1 +--echo # + +CREATE OR REPLACE TABLE t1(a INT); +DELIMITER $$; +CREATE FUNCTION f1() RETURNS VARCHAR(16383) +BEGIN + INSERT INTO t1 VALUES(1); + RETURN 'test'; +END; +$$ +DELIMITER ;$$ +--error ER_UPDATE_TABLE_USED +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +LOCK TABLE t1 WRITE; +--error ER_TABLE_NOT_LOCKED +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +UNLOCK TABLES; + +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 1ee48eed18c5b3a30a4a31b71f8864fc70613a06..3455b0437c1052d34203a6f29e4036a8efc52e97 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -389,6 +389,15 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(c,0)='3 ' AND COALESCE(d,0)=COALESCE(c,0); DROP TABLE t1; +--echo # +--echo # MDEV-15005 ASAN: stack-buffer-overflow in my_strnncollsp_simple +--echo # + +SET NAMES latin1; +SELECT CONVERT(1, CHAR) IN ('100', 10, '101'); +SELECT CONVERT(1, CHAR) IN ('100', 10, '1'); +SELECT CONVERT(1, CHAR) IN ('100', '10', '1'); + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index e21cd1f00227d975f072d915723772daa43b0ff6..0055a2f20e25c2c72fcb8850aa016a1de9b782cb 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -848,6 +848,28 @@ DESCRIBE t1; DROP TABLE t1; +--echo # +--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way +--echo # + +SET NAMES utf8; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); + +SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +--replace_column 1 xxxxxxxxxxxxxxxxx +SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; + +SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +--replace_column 1 xxxxxxxxxxxxxxxxx +SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; + +SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1; +--replace_column 1 xxxxxxxxxxxxxxxxx +SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1; +DROP TABLE t1; + + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index e013109d0a7cf7aef1f304fc9aa7132c52da5cf4..be17eb461be97488f82aa89971ff3e94db620046 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -2024,6 +2024,16 @@ SELECT CONVERT(_utf8 0xC499 USING latin1); SELECT CAST(_utf8 0xC499 AS CHAR CHARACTER SET latin1); +--echo # +--echo # MDEV-15005 ASAN: stack-buffer-overflow in my_strnncollsp_simple +--echo # + +SET NAMES utf8; +SELECT CONVERT(1, CHAR) IN ('100', 10, '101'); +SELECT CONVERT(1, CHAR) IN ('100', 10, '1'); +SELECT CONVERT(1, CHAR) IN ('100', '10', '1'); + + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 77ace1952172bcbd9e3b79989e5716592844a7ba..af4c169091a028300b362acb29b1f35483ca3a86 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1841,6 +1841,25 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub; SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub; SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; +--echo # +--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way +--echo # + +SET NAMES utf8mb4; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); + +SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(UUID(), "-", "") AS c FROM t1) AS d1; +--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1; + +SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1; +--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx +SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1; + +DROP TABLE t1; + + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test index 2c93f75cb5ad3cbdeed077722c026b8952065a26..7807d1a9f9e6dd74ae8844b8abdb1c8ec5cfddf4 100644 --- a/mysql-test/t/dyncol.test +++ b/mysql-test/t/dyncol.test @@ -928,6 +928,15 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',1 AS DECIMAL,'b',1 AS DECIMAL)); SELECT COLUMN_JSON(COLUMN_CREATE('test','"\\\t\n\Z')) AS json; SELECT COLUMN_JSON(COLUMN_CREATE('test','First line\nSecond line')) AS json; +--echo # +--echo # MDEV-15230: column_json breaks cyrillic in 10.1.31 +--echo # +set names utf8; +create table t1 (b blob); +insert into t1 values (column_create('description',column_create('title','ОпиÑание'))); +select column_json(b) from t1; +drop table t1; + --echo # --echo # end of 10.0 tests --echo # diff --git a/mysql-test/t/fast_prefix_index_fetch_innodb.test b/mysql-test/t/fast_prefix_index_fetch_innodb.test index e563e65ec2a0aa9a410b8616ad8ea5a943b8d21e..c3b3440d82d5380840c235fbd41cc2300a4f02e0 100644 --- a/mysql-test/t/fast_prefix_index_fetch_innodb.test +++ b/mysql-test/t/fast_prefix_index_fetch_innodb.test @@ -31,120 +31,638 @@ select * from prefixinno; let $show_count_statement = show status like 'innodb_secondary_index_triggered_cluster_reads'; let $show_opt_statement = show status like 'innodb_secondary_index_triggered_cluster_reads_avoided'; ---disable_query_log - --echo # Baseline sanity check: 0, 0. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select "no-op query"; ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Eligible for optimization. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('d', 31); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Eligible for optimization, access via fake_id only. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where fake_id = 1031; ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Not eligible for optimization, access via fake_id of big row. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where fake_id = 1033; ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Not eligible for optimization. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('x', 32); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Not eligible for optimization. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('y', 33); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Eligible, should not increment lookup counter. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('b', 8); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Eligible, should not increment lookup counter. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('c', 24); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Should increment lookup counter. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + select id, bigfield from prefixinno where bigfield = repeat('z', 128); ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; --echo # Disable optimization, confirm we still increment counter. ---let $base_count = query_get_value($show_count_statement, Value, 1) ---let $base_opt = query_get_value($show_opt_statement, Value, 1) +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + set global innodb_prefix_index_cluster_optimization = OFF; select id, bigfield from prefixinno where fake_id = 1033; ---let $count = query_get_value($show_count_statement, Value, 1) + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log eval select $count - $base_count into @cluster_lookups; -select @cluster_lookups = 1 as cluster_lookups_matched; ---let $opt = query_get_value($show_opt_statement, Value, 1) -eval select $opt - $base_opt into @cluster_lookups; -select @cluster_lookups = 0 as cluster_lookups_avoided_matched; +eval select $opt - $base_opt into @cluster_lookups_avoided; +--enable_query_log +select @cluster_lookups; +select @cluster_lookups_avoided; ---echo # make test suite happy by cleaning up our mess drop table prefixinno; + +--echo # Multi-byte handling case + +set global innodb_prefix_index_cluster_optimization = ON; +SET NAMES utf8mb4; +CREATE TABLE t1( + f1 varchar(10) CHARACTER SET UTF8MB4 COLLATE UTF8MB4_BIN, + INDEX (f1(3)))ENGINE=INNODB; + +INSERT INTO t1 VALUES('a'), ('cccc'), ('až'), ('cÄc'), ('ggáµ·g'), ('¢¢'); +INSERT INTO t1 VALUES('தமிழà¯'), ('ðŸ±ðŸŒ‘'), ('🌒'), ('🌑'); +INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢'); + +--echo # Eligible - record length is shorter than prefix +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழà¯'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggáµ·%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '¢¢%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ðŸ±ðŸŒ‘%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +DROP TABLE t1; + +--echo # Multi-byte with minimum character length > 1 bytes + +CREATE TABLE t1( + f1 varchar(10) CHARACTER SET UTF16 COLLATE UTF16_BIN, + INDEX (f1(3)))ENGINE=INNODB; + +INSERT INTO t1 VALUES('a'), ('cccc'), ('až'), ('cÄc'), ('ggáµ·g'), ('¢¢'); +INSERT INTO t1 VALUES('தமிழà¯'), ('ðŸ±ðŸŒ‘'), ('🌒'), ('🌑'); +INSERT INTO t1 VALUES('😊me'), ('eu€'), ('ls¢'); + +--echo # Eligible - record length is shorter than prefix +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'a'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'c%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'až'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'தமிழà¯'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ggáµ·%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '😊%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 = 'ls¢'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX(`f1`) WHERE f1 like '¢¢%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like 'ðŸ±ðŸŒ‘%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length is shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌑%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Eligible - record length is shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT f1 FROM t1 FORCE INDEX (`f1`) WHERE f1 like '🌒%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +DROP TABLE t1; + +CREATE TABLE t1( + col1 INT, + col2 BLOB DEFAULT NULL, + INDEX `idx1`(col2(4), col1))ENGINE=INNODB; +INSERT INTO t1 VALUES (2, 'test'), (3, repeat('test1', 2000)); +INSERT INTO t1(col1) VALUES(1); + +--echo # Eligible - record length is shorter than prefix length + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 is NULL; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +--echo # Not eligible - record length longer than prefix index + +let $base_count = query_get_value($show_count_statement, Value, 1); +let $base_opt = query_get_value($show_opt_statement, Value, 1); + +SELECT col1 FROM t1 FORCE INDEX (`idx1`) WHERE col2 like 'test1%'; + +let $count = query_get_value($show_count_statement, Value, 1); +let $opt = query_get_value($show_opt_statement, Value, 1); + +--disable_query_log +eval set @cluster_lookups = $count - $base_count; +eval set @cluster_lookups_avoided = $opt - $base_opt; +--enable_query_log + +select @cluster_lookups; +select @cluster_lookups_avoided; + +DROP TABLE t1; set global innodb_prefix_index_cluster_optimization = OFF; diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test index 5f27978347c44d772f092938568e08415086a970..e7e2b96f0ebd5ea8cb5043136127f3f906959d52 100644 --- a/mysql-test/t/func_date_add.test +++ b/mysql-test/t/func_date_add.test @@ -100,3 +100,40 @@ drop table t1; --echo End of 5.5 tests +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-14452 Precision in INTERVAL xxx DAY_MICROSECOND parsed wrong? +--echo # + +--vertical_results +SELECT + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5' DAY_MICROSECOND) c1, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50' DAY_MICROSECOND) c2, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500' DAY_MICROSECOND) c3, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000' DAY_MICROSECOND) c4, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000' DAY_MICROSECOND) c5, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000' DAY_MICROSECOND) c6, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000' DAY_MICROSECOND) c7, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000' DAY_MICROSECOND) c8, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000' DAY_MICROSECOND) c9, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000' DAY_MICROSECOND) c10, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000' DAY_MICROSECOND) c11, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000' DAY_MICROSECOND) c12, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000' DAY_MICROSECOND) c13, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000' DAY_MICROSECOND) c14, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000000' DAY_MICROSECOND) c15, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000000' DAY_MICROSECOND) c16, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000000' DAY_MICROSECOND) c17, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.500000000000000000' DAY_MICROSECOND) c18, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.5000000000000000000' DAY_MICROSECOND) c19, + DATE_ADD('1000-01-01 00:00:00', INTERVAL '0 00:00:01.50000000000000000000' DAY_MICROSECOND) c20 +; +--horizontal_results + + +--echo # +--echo # End of 10.1 tests +--echo # diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index ffb7838ee787b4abcaf3c720dc531fcb22957666..2509f55ccbb4785ac9d86d941cf9adc155f4c5f2 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -606,6 +606,17 @@ SELECT NAME_CONST('a', -(1 OR 2)) OR 1; SELECT NAME_CONST('a', -(1 AND 2)) OR 1; SELECT NAME_CONST('a', -(1)) OR 1; +--echo # +--echo # MDEV-15630 uuid() function evaluates at wrong time in query +--echo # + +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3); +--replace_column 2 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +SELECT COUNT(1), UUID() as uid FROM t1 GROUP BY uid; +DROP TABLE t1; + + --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index b3143ecbc86144f773048b40b7e4c5e824eb0f29..46b4dc2e3f0b6ff1d4a4756dcdb0acbee32336de 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1768,6 +1768,41 @@ EXPLAIN EXTENDED SELECT CHAR(0xDF USING latin1); EXPLAIN EXTENDED SELECT CHAR(0xDF USING `binary`); EXPLAIN EXTENDED SELECT CHAR(0xDF); +--echo # +--echo # MDEV-15619 using CONVERT() inside AES_ENCRYPT() in an UPDATE corrupts data +--echo # + +CREATE TABLE t1 ( + id int(11) NOT NULL, + session_id varchar(255) DEFAULT NULL, + directory mediumtext, + checksum int(10) DEFAULT NULL, + last_update datetime DEFAULT NULL, + PRIMARY KEY (id), + KEY lastupdate (last_update) +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,'',NULL,38391,'2017-06-24 07:35:28'); +UPDATE t1 SET directory = AES_ENCRYPT(CONVERT('test stringrererejrjerjehrjekhrjkehrjkehrkjehrjkerhkjehrjekrhkjehrkjerhjkehrkjehrkjehrjkehrjkehrjkehrjkerjkehrjkehrjkehrjke rekjhrejrejhrjehgrehjgrhjerjhegrjherejhgrjhegrjehgrjhegrejhrgjehgrjhegrjhegrjhergjhegrjhegrhjegrjerhthkjjkdhjkgdfjkgjkdgdjkfjkhgjkfdhjgjkfdghkjdfghkjfdghfjkdghkdjfghdkjfghfjkdghfkjdghkjfdghfkjdghfkdjghfkjdghfdjkghjkdfhgdfjkghfjkdghfjkdghfjdkghfjkdghkfjdghfkjdghfkjdghkjdfghfjdkghjkfdghkjdfhgjkdfhgjkfdhgkjfdghkfjdhgkjfdgdjkejktjherjthkjrethkjrethjkerthjkerhtjkerhtkjerhtjkerhtjkerhtjkrehtkjerhtkjrehtjkrehtkjrehtkjerhtkjerhtjkrehtkjrehtjkrehtkjrethjkrethkjrehtkjethjkerhtjkrehtjkretkjerhtkjrehtjkerhtjkrehtjrehtkjrekjtrfgdsfgdhjsghjgfdhjsfhjdfgdhjshjdshjfghjdsfgjhsfgjhsdfgjhdsfgjdhsfgsjhfgjhsdfgsdjhfgjdhsfdjshfgdsjhfgjsdhfdjshfgdjhsfgdjshfgjdhsfgjhsdfgjhsdgfjhsdgfjhdsgfjhsgfjhsdgfjhdsgfhjsdehkjthrkjethjkre' USING latin1), '95F5A1F52A554'), last_update= NOW(); +SELECT directory IS NULL FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + id int(11) NOT NULL PRIMARY KEY, + directory mediumtext +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,AES_ENCRYPT(CONVERT(REPEAT('a',800) USING latin1),'95F5A1F52A554')); +SELECT AES_DECRYPT(directory,'95F5A1F52A554') FROM t1; +DROP TABLE t1; + +SET @enc=AES_ENCRYPT(REPEAT(_latin1'a',800),'95F5A1F52A554'); +CREATE TABLE t1 ( + id int(11) NOT NULL PRIMARY KEY, + directory mediumtext +) DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,AES_DECRYPT(CONVERT(@enc USING binary),'95F5A1F52A554')); +SELECT * FROM t1; +DROP TABLE t1; + --echo # --echo # Start of 10.1 tests --echo # diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index bc553e6f0493afc584999c7011b7ae686defef4c..380822130045c513dbd161e2282b84f780c9a6bc 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1762,6 +1762,22 @@ SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:0:0:315569433559' DAY_SECOND) SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:0:315569433559' DAY_SECOND); SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:315569433599' DAY_SECOND); +--echo # +--echo # MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime +--echo # + +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '1970-01-01'); +SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR); +DROP TABLE t1; + +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '1970-01-01'); +SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1; +DROP TABLE t1; + +SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR)); + --echo # --echo # End of 10.0 tests diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index a8ddf350b736e9938269554b18f5c542775b2483..51d59844da68765042583ef38b832308e3f65888 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1568,15 +1568,7 @@ drop database mysqltest1; --echo End of 5.0 tests - -# -# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte -# set names utf8; -grant select on test.* to юзер_юзер@localhost; ---exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()" -revoke all on test.* from юзер_юзер@localhost; -drop user юзер_юзер@localhost; --error ER_WRONG_STRING_LENGTH grant select on test.* to очень_длинный_юзер890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890@localhost; set names default; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index a40fd2afb1853079cf8fa68500a4e5a7a814c90a..f0721b3e5e90140c8bdc4e446dd81a72ac097106 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -875,9 +875,8 @@ CACHE INDEX t3 IN keycache1; LOAD INDEX INTO CACHE t3; --echo # ---echo # RENAME (doesn't work for temporary tables, thus should fail). +--echo # RENAME should work for temporary tables --echo # ---error ER_TABLEACCESS_DENIED_ERROR RENAME TABLE t3 TO t3_1; --echo # diff --git a/mysql-test/t/grant_not_windows.test b/mysql-test/t/grant_not_windows.test new file mode 100644 index 0000000000000000000000000000000000000000..55b09232edc9e4b3518916afef7e576ed9d34e78 --- /dev/null +++ b/mysql-test/t/grant_not_windows.test @@ -0,0 +1,14 @@ + # UTF8 parameters to mysql client do not work on Windows +--source include/not_windows.inc +--source include/not_embedded.inc + +# +# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte +# +set names utf8; +create user юзер_юзер@localhost; +grant select on test.* to юзер_юзер@localhost; +--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()" +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +set names default; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 1bbde3e7c5e16ed6432fd428ce976d099ae9a931..dadeaca35b65ff79c0dcdfe70493c6bb13b6f407 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -759,6 +759,24 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1; DROP TABLE t1,t2; +--echo # +--echo # MDEV-6736: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SQ +--echo # in WHERE and HAVING, ORDER BY, materialization+semijoin +--echo # + +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (3),(8); + +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (2),(1); + +SELECT a FROM t1 +WHERE 9 IN ( SELECT MIN( a ) FROM t1 ) +HAVING a <> ( SELECT COUNT(*) FROM t2 ) +ORDER BY a; + +DROP TABLE t1,t2; + --echo End of 10.0 tests --echo # diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index bcd87c2688d76f4d41a75ea8e111d377105db14d..385e372bc3b795fdca31c646d2c0609c83cf4f90 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -423,3 +423,13 @@ SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size; DROP TABLE t1; --echo End of 5.1 tests + +# +# MDEV-15318 CREATE .. SELECT VALUES produces invalid table structure +# +create table t1 (i int); +create table t2 as select values(i) as a from t1; +show create table t2; +drop table t1, t2; + +--echo End of 5.5 tests diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index acbe19b5e877f365f566a68f7de3087f6428ec70..34b0551a32ed7e4ba8c32d6ee4e500ba0fab5f33 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1972,9 +1972,25 @@ INSERT INTO t1 VALUES (0),(1); CREATE TABLE t2 (b2 BIT NOT NULL); INSERT INTO t2 VALUES (0),(1); -SET SESSION JOIN_CACHE_LEVEL = 3; +set @save_join_cache_level= @@join_cache_level; +SET @@join_cache_level = 3; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; DROP TABLE t1, t2; +set @join_cache_level= @save_join_cache_level; + +--echo # +--echo # MDEV-14779: using left join causes incorrect results with materialization and derived tables +--echo # + +create table t1(id int); +insert into t1 values (1),(2); +create table t2(sid int, id int); +insert into t2 values (1,1),(2,2); + +select * from t1 t + left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r + on t.id=r.id ; +drop table t1, t2; --echo # end of 5.5 tests diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index 4dbe13096d4176595485ff28c778a9fcc370736c..668d3b745185ff9b4c098cf6089358ea2bdbbc6d 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -115,3 +115,17 @@ SELECT a FROM t1 ORDER BY a LIMIT 2 OFFSET 14; DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # mdev-16235: SELECT over a table with LIMIT 0 +--echo # + +EXPLAIN +SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0; +SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0; + +EXPLAIN +SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0; +SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0; + +--echo End of 5.5 tests diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 78f0e2ecf8d853c61cf96e70ae0d70839f767f3e..6cfaf9fc320b201ac689abb733140c70b592d2e5 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -481,7 +481,7 @@ LOCK TABLE t1 WRITE; --echo # HANDLER commands are not allowed in LOCK TABLES mode --error ER_LOCK_OR_ACTIVE_TRANSACTION HANDLER t1 OPEN; ---error ER_LOCK_OR_ACTIVE_TRANSACTION +--error ER_LOCK_OR_ACTIVE_TRANSACTION,ER_UNKNOWN_TABLE HANDLER t1 READ FIRST; --error ER_LOCK_OR_ACTIVE_TRANSACTION HANDLER t1 CLOSE; diff --git a/mysql-test/t/mdev375.test b/mysql-test/t/mdev375.test index fe259b378082d510f7bf8416e85a429607722d24..7380e7a32e15b9b17d949ec9bc8b3703b0c4c462 100644 --- a/mysql-test/t/mdev375.test +++ b/mysql-test/t/mdev375.test @@ -4,7 +4,16 @@ --source include/not_embedded.inc SET GLOBAL log_warnings=4; -SET GLOBAL max_connections=2; +SET GLOBAL max_connections=10; + +--connect (tmp_con1,localhost,root,,) +--connect (tmp_con2,localhost,root,,) +--connect (tmp_con3,localhost,root,,) +--connect (tmp_con4,localhost,root,,) +--connect (tmp_con5,localhost,root,,) +--connect (tmp_con6,localhost,root,,) +--connect (tmp_con7,localhost,root,,) +--connect (tmp_con8,localhost,root,,) --connect (con1,localhost,root,,) SELECT 1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 62260ba43aa0a6173dade806b3c07153fc937672..77baa695b6dc3a9ada1f02e59b4041d28c01493d 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1216,13 +1216,14 @@ DROP TABLE t1; --echo # --echo # BUG#48438 - crash with error in unioned query against merge table and view... --echo # -SET GLOBAL table_open_cache=3; +SET @save_table_open_cache=@@table_open_cache; +SET GLOBAL table_open_cache=10; CREATE TABLE t1(a INT); -SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE; +SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4, t1 AS a5, t1 AS a6, t1 AS a7, t1 AS a8, t1 AS a9, t1 AS a10, t1 AS a11 FOR UPDATE; SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; DROP TABLE t1; -SET GLOBAL table_open_cache=DEFAULT; +SET GLOBAL table_open_cache=@save_table_open_cache; --echo End of 5.0 tests @@ -1762,6 +1763,19 @@ ALTER TABLE t1 DISABLE KEYS; OPTIMIZE TABLE t1; DROP TABLE t1; +# +# Check FLUSH FOR EXPORT +# + +CREATE TABLE t1(a INT, b CHAR(10), KEY(a), KEY(b)) engine=myisam; +INSERT INTO t1 VALUES(1,'0'),(2,'0'),(3,'0'),(4,'0'),(5,'0'), + (6,'0'),(7,'0'); +flush tables test.t1 for export; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +insert into t1 values (8,'0'); +unlock tables; +drop table t1; + # # Check some variables # diff --git a/mysql-test/t/myisam_recover.test b/mysql-test/t/myisam_recover.test index 49fe9c334608e0aa8e2fe4249fa6fcdd79bc4581..670dfd1aa496614a033ec77f76ec3561889f2536 100644 --- a/mysql-test/t/myisam_recover.test +++ b/mysql-test/t/myisam_recover.test @@ -24,6 +24,7 @@ call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:"); call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); +set @save_table_open_cache=@@table_open_cache; set global table_open_cache=256; set global table_definition_cache=400; --disable_warnings @@ -111,7 +112,7 @@ prepare stmt from @drop_table_stmt; execute stmt; deallocate prepare stmt; set @@global.table_definition_cache=default; -set @@global.table_open_cache=default; +set @@global.table_open_cache=@save_table_open_cache; disconnect con1; connection default; --enable_ps_protocol diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 300695612fdee5053d633c78aa40b9f83a5d89c7..fc2ae849aa61b38b72d2e3a9faff4441fa51b8f6 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -53,14 +53,22 @@ drop table t1; # # Bug#17939 Wrong table format when using UTF8 strings -# ---exec $MYSQL --default-character-set=utf8 --table -e "SELECT 'John Doe' as '__tañgè Ñãmé'" 2>&1 ---exec $MYSQL --default-character-set=utf8 --table -e "SELECT '__tañgè Ñãmé' as 'John Doe'" 2>&1 +write_file $MYSQL_TMP_DIR/mysql_in; +SELECT 'John Doe' as '__tañgè Ñãmé'; +SELECT '__tañgè Ñãmé' as 'John Doe'; +EOF +--exec $MYSQL --default-character-set=utf8 --table < $MYSQL_TMP_DIR/mysql_in 2>&1 +remove_file $MYSQL_TMP_DIR/mysql_in; # # Bug#18265 -- mysql client: No longer right-justifies numeric columns # ---exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('Τη γλώσσα'); insert into t1 (k) values ('á›–áš´ áš·á›–á›'); select * from t1; DROP TABLE t1;" +write_file $MYSQL_TMP_DIR/mysql_in; +create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('Τη γλώσσα'); insert into t1 (k) values ('á›–áš´ áš·á›–á›'); select * from t1; DROP TABLE t1; +EOF +--exec $MYSQL -t --default-character-set utf8 test < $MYSQL_TMP_DIR/mysql_in +remove_file $MYSQL_TMP_DIR/mysql_in; + # # "DESCRIBE" commands may return strange NULLness flags. diff --git a/mysql-test/t/mysql_cp932.test b/mysql-test/t/mysql_cp932.test index 60a129c3805fb11efeb0287fb577d8fd641c7278..8fba5750d898f7ad0e4a53a7b628706fc6c7296c 100644 --- a/mysql-test/t/mysql_cp932.test +++ b/mysql-test/t/mysql_cp932.test @@ -10,13 +10,43 @@ # BUG#16217 - MySQL client misinterprets multi-byte char as escape `\' # +let $mysql_in= $MYSQL_TMP_DIR/mysql_in; + # new command \C or charset ---exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g" ---exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" +write_file $mysql_in; +\C cp932 \g +EOF +--exec $MYSQL --default-character-set=utf8 test < $mysql_in +remove_file $mysql_in; + +write_file $mysql_in; +charset utf8; +EOF +--exec $MYSQL --default-character-set=cp932 test < $mysql_in +remove_file $mysql_in; # its usage to switch internally in mysql to requested charset ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" +write_file $mysql_in; +charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1; +EOF +--exec $MYSQL --default-character-set=utf8 test < $mysql_in +remove_file $mysql_in; + +write_file $mysql_in; +charset cp932; select 'ƒ\' +EOF +--exec $MYSQL --default-character-set=utf8 test < $mysql_in +remove_file $mysql_in; + +write_file $mysql_in; +/*charset cp932 */; set character_set_client= cp932; select 'ƒ\' +EOF +--exec $MYSQL --default-character-set=utf8 test < $mysql_in +remove_file $mysql_in; + +write_file $mysql_in; +/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\' +EOF +--exec $MYSQL --default-character-set=utf8 test < $mysql_in +remove_file $mysql_in; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index fca334a7fee8cc2acc078bceef84fc9a9ec8dacb..aacb812c84f1cd1fa47ed71d880ddba347ac96ed 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2627,3 +2627,25 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/bug11505.sql; let SEARCH_PATTERN=Database: mysql; exec $MYSQL_DUMP mysql func > $SEARCH_FILE; source include/search_pattern_in_file.inc; + +--echo # +--echo # MDEV-15021: Fix the order in which routines are called +--echo # +use test; +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v1 AS SELECT f(); + +--echo # Running mysqldump -uroot test --routines --tables v1 > **vardir**/test.dmp +--exec $MYSQL_DUMP -uroot test --routines --tables v1 > $MYSQLTEST_VARDIR/test.dmp + +DROP VIEW v1; +DROP FUNCTION f; + +--echo # Running mysql -uroot test < **vardir**/test.dmp +--exec $MYSQL -uroot test < $MYSQLTEST_VARDIR/test.dmp + +--echo # +--echo # Cleanup after succesful import. +--echo # +DROP VIEW v1; +DROP FUNCTION f; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index c49c4ab3d7d62572bea8475f3a8fca159b67a6be..81115d59d0920f9c8bfcfa60750d52696deaf877 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -80,3 +80,11 @@ DROP DATABASE bug58090; --exec $MYSQL_SLAP --create-schema=test --init-command="CREATE TABLE t1(a INT)" --silent --concurrency=1 --iterations=1 DROP TABLE t1; + +--echo # +--echo # Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK +--echo # + +--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --create-schema=slap + +--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-secondary-indexes=1 --create-schema=slap diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index b2eb101a37cbdbfb156efc7856c72440d42065ac..60f41042d562cc782b57a0aa51426cc52625effe 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -685,7 +685,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; # Too many errorcodes specified --error 1 ---exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1 +--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11,12,13" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index fec5df1a1c79f2cbec06ed30a8f261ed68acb727..4a61cebdc0d9f68140cbeb487443ce95cfdb57f0 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -404,3 +404,26 @@ SELECT DISTINCT b FROM t1, t2 GROUP BY a, b WITH ROLLUP; DROP TABLE t1, t2; --echo End of 5.0 tests + + +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with time field, ROLLUP and HAVING +--echo # +CREATE TABLE t1 (t TIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('12:12:12'); +SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00'; +DROP TABLE t1; + +CREATE TABLE t1 (t TIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('12:12:12'),('12:12:13'); +SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00'; +DROP TABLE t1; + + +--echo # +--echo # End of 10.1 tests +--echo # diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index e27db9c4e4892eb99c6a71d115cd6a62102edf24..1aba207fd62615148ea29a07bdf84576fe8e63e5 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -781,6 +781,15 @@ CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\; PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\'; DROP TABLE t1; +--echo # +--echo # MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger +--echo # + +CREATE TABLE t1 (a INT); +--error ER_UNKNOWN_SYSTEM_VARIABLE +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @@NEW.a=0; +DROP TABLE t1; + # # start of 10.1 tests # diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index f7008f570b8447cd775cc688629f2a759ec2dd70..e1e8dfeeb17dc47be6f6ad7be794f07d991dd9a9 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -3876,3 +3876,58 @@ FROM ) X; drop table t1; --echo # End of 5.5 tests + +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command +--echo # (the 10.1 part) +--echo # + +DELIMITER /; +CREATE PROCEDURE p2 () +BEGIN + SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; +END; +/ +DELIMITER ;/ +CALL p2(); +DROP PROCEDURE p2; + + +DELIMITER /; +BEGIN NOT ATOMIC + SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN NOT ATOMIC + SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR PREPARE stmt FROM 'SELECT 1'; + DEALLOCATE PREPARE stmt; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN NOT ATOMIC + PREPARE stmt FROM 'SELECT 1'; + SET STATEMENT join_cache_level=CAST(CONCAT(_utf8'6',_latin1'') AS INT) FOR EXECUTE stmt; + DEALLOCATE PREPARE stmt; +END; +/ +DELIMITER ;/ + + +--echo # +--echo # End of 10.1 tests +--echo # diff --git a/mysql-test/t/ps_qc_innodb.test b/mysql-test/t/ps_qc_innodb.test new file mode 100644 index 0000000000000000000000000000000000000000..e09a2bf4070b6c96e39b3d4c433200cbe6ad8a2b --- /dev/null +++ b/mysql-test/t/ps_qc_innodb.test @@ -0,0 +1,35 @@ +--source include/have_query_cache.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-15492: Subquery crash similar to MDEV-10050 +--echo # + +SET @qcs.save= @@global.query_cache_size, @qct.save= @@global.query_cache_type; +SET GLOBAL query_cache_size= 512*1024*1024, query_cache_type= ON; + +--connect (con1,localhost,root,,test) +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (b INT) ENGINE=InnoDB; +CREATE VIEW v AS select a from t1 join t2; + +PREPARE stmt1 FROM "SELECT * FROM t1 WHERE a in (SELECT a FROM v)"; + +--connect (con2,localhost,root,,test) +PREPARE stmt2 FROM "SELECT * FROM t1 WHERE a in (SELECT a FROM v)"; +EXECUTE stmt2; + +--connection con1 +EXECUTE stmt1; +INSERT INTO t2 VALUES (0); +EXECUTE stmt1; +START TRANSACTION; +EXECUTE stmt1; + +# Cleanup +--disconnect con1 +--disconnect con2 +--connection default +DROP VIEW v; +DROP TABLE t1, t2; +SET GLOBAL query_cache_size= @qcs.save, query_cache_type= @qct.save; diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test index a55bc845acce16c080be4f5c057531b95940abfc..67732d5b5b955623717fb3e358f56d269f080a9c 100644 --- a/mysql-test/t/rename.test +++ b/mysql-test/t/rename.test @@ -95,3 +95,49 @@ drop table t1; --source include/wait_until_count_sessions.inc +# +# Test of rename with temporary tables +# + +CREATE OR REPLACE TABLE t1 (a INT); +CREATE OR REPLACE TABLE t2 (a INT); +CREATE OR REPLACE TEMPORARY TABLE t1_tmp (b INT); +CREATE OR REPLACE TEMPORARY TABLE t2_tmp (b INT); + +# Can't rename table over another one +--error ER_TABLE_EXISTS_ERROR +rename table t1 to t2; +--error ER_TABLE_EXISTS_ERROR +rename table t1 to tmp, tmp to t2; +--error ER_TABLE_EXISTS_ERROR +rename table t1_tmp to t2_tmp; +--error ER_TABLE_EXISTS_ERROR +rename table t1_tmp to tmp, tmp to t2_tmp; + +show create table t1_tmp; +show create table t2_tmp; + +# The following should work +rename table t1 to t1_tmp; +rename table t2_tmp to t2; +rename table t2 to tmp, tmp to t2; +rename table t1_tmp to tmp, tmp to t1_tmp; +show tables; +SHOW CREATE TABLE t1_tmp; +drop table t1_tmp; +SHOW CREATE TABLE t1_tmp; +drop table t1_tmp; +SHOW CREATE TABLE t2; +drop table t2; +SHOW CREATE TABLE t2; +drop table t2; + +CREATE TABLE t1 (a INT); +insert into t1 values (1); +CREATE TEMPORARY TABLE t1 (b INT); +insert into t1 values (2); +RENAME TABLE t1 TO tmp, t1 TO t2; +select * from tmp; +select * from t2; +drop table tmp,t2; + diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test index 3e60f242083e2ec42eb5fcf8ddc2d44ece633ab7..cf12bdaea219d44675ec8702775f87ff35c564b4 100644 --- a/mysql-test/t/selectivity.test +++ b/mysql-test/t/selectivity.test @@ -1045,6 +1045,24 @@ SELECT * FROM (SELECT t FROM t1 WHERE d IS NULL) sq; DROP TABLE t1; +--echo # +--echo # MDEV-16374: filtered shows 0 for materilization scan for a semi join, which makes optimizer +--echo # always pick materialization scan over materialization lookup +--echo # + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int); +insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10), +(11,11),(12,12),(13,13),(14,14),(15,15); +set @@optimizer_use_condition_selectivity=2; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +select * from t1 where a in (select max(a) from t1 group by b); +set @@optimizer_use_condition_selectivity=1; +explain extended select * from t1 where a in (select max(a) from t1 group by b); +select * from t1 where a in (select max(a) from t1 group by b); +drop table t1,t0; + set histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set use_stat_tables=@save_use_stat_tables; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index 6e19fd885e31d1ae7d61cba762ad19bf0698af60..9d43245d56e8d7e5747d557226324ab82968b94e 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -285,3 +285,13 @@ create database mysqltest1; create procedure mysqltest1.foo() select "foo"; update mysql.proc set name='' where db='mysqltest1'; drop database mysqltest1; + +# +# BUG#26881798: SERVER EXITS WHEN PRIMARY KEY IN MYSQL.PROC IS DROPPED +# +create procedure p1() set @foo = 10; +alter table mysql.proc drop primary key; +--error ER_CANNOT_LOAD_FROM_TABLE_V2 +drop procedure p1; +alter table mysql.proc add primary key (db,name,type); +drop procedure p1; diff --git a/mysql-test/t/sp-innodb.test b/mysql-test/t/sp-innodb.test index 23715166a027fe912f1bf8f5dacc6ddbb93a3ca8..e44a853e713ad6f0c78e560e7d19c4bd33f1b6a0 100644 --- a/mysql-test/t/sp-innodb.test +++ b/mysql-test/t/sp-innodb.test @@ -158,5 +158,47 @@ SET @@innodb_lock_wait_timeout= @innodb_lock_wait_timeout_saved; --echo # BUG 16041903: End of test case --echo # +--echo # +--echo # MDEV-15035: SP using query with outer join and a parameter +--echo # in ON expression +--echo # + +CREATE TABLE t1 ( + id int NOT NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1), (2); + +CREATE TABLE t2 ( + id int NOT NULL, + id_foo int NOT NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB; + +INSERT INTO t2 VALUES (1, 1); + +--disable_warnings +DROP PROCEDURE IF EXISTS test_proc; +--enable_warnings + +DELIMITER |; +CREATE PROCEDURE test_proc(IN param int) +LANGUAGE SQL +READS SQL DATA +BEGIN + SELECT DISTINCT f.id + FROM t1 f + LEFT OUTER JOIN t2 b ON b.id_foo = f.id + WHERE (param <> 0 OR b.id IS NOT NULL); +END| +DELIMITER ;| + +CALL test_proc(0); +CALL test_proc(1); + +DROP PROCEDURE IF EXISTS test_proc; +DROP TABLE t1, t2; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 4b2230ea7da0567ec2fed06ee9edeceb958d96ad..467d3b5a7d4c9bac04ea68ecf7220c058314b699 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -9408,7 +9408,7 @@ DELIMITER ;| set @tmp_toc= @@table_open_cache; set @tmp_tdc= @@table_definition_cache; -set global table_open_cache=1; +set global table_open_cache=10; set global table_definition_cache=1; call p1(); @@ -9754,4 +9754,19 @@ DROP TABLE t1, t2; SET max_sp_recursion_depth=default; +--echo # +--echo # MDEV-15347: Valgrind or ASAN errors in mysql_make_view on query +--echo # from information_schema +--echo # + +CREATE VIEW v AS SELECT 1; +CREATE FUNCTION f() RETURNS INT RETURN 1; +--disable_result_log +SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS +UNION +SELECT * FROM INFORMATION_SCHEMA.TABLES JOIN INFORMATION_SCHEMA.PARAMETERS; +--enable_result_log +DROP FUNCTION f; +DROP VIEW v; + --echo #End of 10.1 tests diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test index 3f08e2e133cb123c98d89b22701691aedf1fce8a..0463885e41a61b2065554ecaa0244b0cdc43ec2a 100644 --- a/mysql-test/t/statistics.test +++ b/mysql-test/t/statistics.test @@ -729,6 +729,25 @@ select db_name, table_name, column_name, drop table t1; +--echo # +--echo # MDEB-9744: session optimizer_use_condition_selectivity=5 causing SQL Error (1918): +--echo # Encountered illegal value '' when converting to DECIMAL +--echo # + +set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=3, use_stat_tables=preferably; + +create table t1 (id int(10),cost decimal(9,2)) engine=innodb; +ANALYZE TABLE t1 PERSISTENT FOR ALL; + +create temporary table t2 (id int); +insert into t2 (id) select id from t1 where cost > 0; +select * from t2; + +set use_stat_tables=@save_use_stat_tables; +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +drop table t1,t2; + --echo # --echo # MDEV-9590: Always print "Engine-independent statistic" warnings and --echo # might be filtering columns unintentionally from engines diff --git a/mysql-test/t/statistics_close.test b/mysql-test/t/statistics_close.test new file mode 100644 index 0000000000000000000000000000000000000000..de22a5a44febdff838a081fb65b19e2f7498bfe6 --- /dev/null +++ b/mysql-test/t/statistics_close.test @@ -0,0 +1,18 @@ +# +# MDEV-16123 ASAN heap-use-after-free handler::ha_index_or_rnd_end +# MDEV-13828 Segmentation fault on RENAME TABLE +# + +CREATE TABLE t1 (i int); +--connect (con1,localhost,root,,test) +--send +RENAME TABLE t1 TO t2; +--connection default +FLUSH TABLES; +--connection con1 +--reap + +# Cleanup +--disconnect con1 +--connection default +DROP TABLE IF EXISTS t1, t2; diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index d4ccbcf6f665fc9ef90a2348c708c1f05d1570b1..d5a404191853184583add75490886c28d1992e9b 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -2032,9 +2032,40 @@ SELECT ( SELECT COUNT(*) FROM t1 WHERE a = c ) AS field, COUNT(DISTINCT c) FROM t2 WHERE b <= 'quux' GROUP BY field; drop table t1,t2; +--echo # +--echo # MDEV-15555: select from DUAL where false yielding wrong result when in a IN +--echo # + +explain +SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1); +SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1); + SET optimizer_switch= @@global.optimizer_switch; set @@tmp_table_size= @@global.tmp_table_size; +--echo # +--echo # MDEV-14515: Wrong results for tableless query with subquery in WHERE +--echo # and implicit aggregation +--echo # + +create table t1 (i1 int, i2 int); +insert into t1 values (1314, 1084),(1330, 1084),(1401, 1084),(580, 1084); + +create table t2 (cd int); +insert into t2 values + (1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330), + (1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330); + +select max(10) from dual + where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345); + +insert into t2 select * from t2; + +select max(10) from dual + where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345); + +DROP TABLE t1,t2; + --echo # --echo # MDEV-10232 Scalar result of subquery changes after adding an outer select stmt --echo # diff --git a/mysql-test/t/subselect_mat.test b/mysql-test/t/subselect_mat.test index 9c7c9683d0bf1f8deee74aeb7c7e42f11603f7b4..bf5de741ea07f1a6144b88cfa24245610f6876a2 100644 --- a/mysql-test/t/subselect_mat.test +++ b/mysql-test/t/subselect_mat.test @@ -255,6 +255,19 @@ FROM t1; drop table t1, t2; +--echo # +--echo # MDEV-15235: Assertion `length > 0' failed in create_ref_for_key +--echo # + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f CHAR(1)); +INSERT INTO t2 VALUES ('a'),('b'); +explain +SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 ); +SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 ); +DROP TABLE t1, t2; + --echo # --echo # MDEV-9489: Assertion `0' failed in Protocol::end_statement() on --echo # UNION ALL diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index f90f1e2e927bac2be29c058080775beaea85712f..623e414310aed2f592c85e22e27ec698f8b4c85e 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2845,5 +2845,35 @@ eval EXPLAIN EXTENDED $q2; DROP TABLE t1,t2,t3,t4; +--echo # +--echo # MDEV-13699: Assertion `!new_field->field_name.str || +--echo # strlen(new_field->field_name.str) == new_field->field_name.length' +--echo # failed in create_tmp_table on 2nd execution of PS with semijoin +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +CREATE TABLE t3 (c INT); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t3 VALUES (5),(6); + +PREPARE stmt FROM + "SELECT * FROM t1 + WHERE EXISTS ( + SELECT * FROM t2 WHERE t1.a IN ( SELECT c AS fld FROM v3 ) + )"; +EXECUTE stmt; +EXECUTE stmt; +EXECUTE stmt; + +drop view v3; +drop table t1,t2,t3; + +--echo # End of 5.5 test + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/t/subselect_sj2_mat.test b/mysql-test/t/subselect_sj2_mat.test index cfb6c8c28199aff933035b7ad4e1c7e5b4bfa318..0665cdf68fef19eaf27cf3285592fcec4d8ad304 100644 --- a/mysql-test/t/subselect_sj2_mat.test +++ b/mysql-test/t/subselect_sj2_mat.test @@ -303,3 +303,45 @@ eval $q; eval explain $q; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-16225: wrong resultset from query with semijoin=on +--echo # + +CREATE TABLE t1 ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `local_name` varchar(64) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1; + +insert into t1(`id`,`local_name`) values +(1,'Cash Advance'), +(2,'Cash Advance'), +(3,'Rollover'), +(4,'AL Installment'), +(5,'AL Installment'), +(6,'AL Installment'), +(7,'AL Installment'), +(8,'AL Installment'), +(9,'AL Installment'), +(10,'Internet Payday'), +(11,'Rollover - Internet Payday'), +(12,'AL Monthly Installment'), +(13,'AL Semi-Monthly Installment'); + +explain +SELECT SQL_NO_CACHE t.id +FROM t1 t +WHERE ( + t.id IN (SELECT A.id FROM t1 AS A WHERE A.local_name IN (SELECT B.local_name FROM t1 AS B WHERE B.id IN (0,4,12,13,1,10,3,11))) + OR + (t.id IN (0,4,12,13,1,10,3,11)) +); +SELECT SQL_NO_CACHE t.id +FROM t1 t +WHERE ( + t.id IN (SELECT A.id FROM t1 AS A WHERE A.local_name IN (SELECT B.local_name FROM t1 AS B WHERE B.id IN (0,4,12,13,1,10,3,11))) + OR + (t.id IN (0,4,12,13,1,10,3,11)) +); +drop table t1; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index ff6f38b719d90b0bda5487de887b58e019cfb615..a6d4107e59151f5e9ed53d0300cd648021b95b41 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2656,5 +2656,17 @@ insert into t2 value (2); DROP VIEW v1; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-16093 +--echo # Assertion `global_status_var.global_memory_used == 0' failed or +--echo # bytes lost after inserting into table with non-null blob and trigger +--echo # + +CREATE TABLE t1 (b BLOB NOT NULL); +CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END; +INSERT INTO t1 VALUES ('foo'); +DROP TABLE t1; ---echo End of 10.1 tests. +--echo # +--echo # End of 10.1 tests. +--echo # diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 27679b9ec5ab076b67bbbaa51889ecdff9c16436..10b75f2754667b0a6e99c79d8027f1f0dd6fcf0d 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -723,6 +723,29 @@ INSERT INTO t1 VALUES ('10:10:10'),('10:20:30'); SELECT MAX(a), MAX(COALESCE(a)) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-15321: different results when using value of optimizer_use_condition_selectivity=4 and =1 +--echo # + +SET @save_old_mode=@@old_mode; +SET @@old_mode=zero_date_time_cast; +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('0000-00-00 10:20:30'),('0000-00-00 10:20:31'); +INSERT INTO t1 VALUES ('0000-00-01 10:20:30'),('0000-00-01 10:20:31'); +INSERT INTO t1 VALUES ('31 10:20:30'),('32 10:20:30'),('33 10:20:30'),('34 10:20:30'); + +SET @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +SET @@optimizer_use_condition_selectivity=1; +SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; + +SET @@optimizer_use_condition_selectivity=4; +SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8; +drop table t1; +SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set @@old_mode= @save_old_mode; + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/type_time_6065.test b/mysql-test/t/type_time_6065.test index 6e29b849be516a479042976da82aa772018de2d8..fc91c5307603301e9c8bdbf0989030d27b9ea2cc 100644 --- a/mysql-test/t/type_time_6065.test +++ b/mysql-test/t/type_time_6065.test @@ -172,6 +172,29 @@ eval $query; DROP TABLE t1,t2,t3; SET TIMESTAMP=0; # back to current time + +--echo # +--echo # MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column +--echo # + +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)); +CREATE TABLE t2 (col_datetime_key DATETIME); +INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00'); +INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00'); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +INSERT INTO t1 VALUES ('-838:59:59'),('838:59:59'); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '838:59:59' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-839:00:00' HOUR_SECOND)); +INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '839:00:00' HOUR_SECOND)); +SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key; +SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key; +DROP TABLE t1, t2; +SET TIMESTAMP=DEFAULT; + # # End of 10.0 tests # diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 8f29528ac25ad6a97db9cf12517794c1af237ac2..458327328e43fc6ce8b71e68dd6a0c0befe596a4 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -343,6 +343,7 @@ set sql_select_limit=1; # reset it, so later tests don't get confused set sql_select_limit=default; set sql_warnings=1; +set @save_table_open_cache=@@table_open_cache; set global table_open_cache=100; set default_storage_engine=myisam; set global thread_cache_size=100; @@ -502,7 +503,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'MYI SET GLOBAL table_open_cache=-1; SHOW VARIABLES LIKE 'table_open_cache'; SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache'; -SET GLOBAL table_open_cache=DEFAULT; +SET GLOBAL table_open_cache=@save_table_open_cache; # # Bugs12363: character_set_results is nullable, diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 68adc6e19e1cce0d057f4a0747ae4405021207d8..6ff226d738f528c0d7096ac24f14c97b079f8f4b 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5182,118 +5182,6 @@ deallocate prepare stmt1; drop view v1,v2; drop table t1,t2; ---echo # ---echo # MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized ---echo # with MERGE view) ---echo # - -CREATE TABLE t1 (a1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t2 (b1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t3 (c1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t4 (d1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t5 (e1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t6 (f1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY); - -CREATE OR REPLACE view v1 AS - SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -; - -SELECT 1 -FROM (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t1) -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t2) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t3) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t4) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t5) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t6) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t7) ON 1=1 -LEFT OUTER JOIN (( SELECT 1 - FROM t1 a_alias_1 - LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1 - LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1 - LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1 - LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1 - LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1 -) t8) ON 1=1 -; - -SELECT 1 -FROM (v1 t1) -LEFT OUTER JOIN (v1 t2) ON 1=1 -LEFT OUTER JOIN (v1 t3) ON 1=1 -LEFT OUTER JOIN (v1 t4) ON 1=1 -LEFT OUTER JOIN (v1 t5) ON 1=1 -LEFT OUTER JOIN (v1 t6) ON 1=1 -LEFT OUTER JOIN (v1 t7) ON 1=1 -LEFT OUTER JOIN (v1 t8) ON 1=1 -; - -drop view v1; -drop table t1,t2,t3,t4,t5,t6; - --echo # ----------------------------------------------------------------- --echo # -- End of 5.3 tests. --echo # ----------------------------------------------------------------- @@ -5603,6 +5491,202 @@ SHOW CREATE VIEW v1; drop view v1; drop table t1; +CREATE TABLE IF NOT EXISTS t0 (f0 INT); +CREATE TABLE IF NOT EXISTS t1 (f1 INT); +CREATE TABLE IF NOT EXISTS t2 (f2 INT); +CREATE TABLE IF NOT EXISTS t3 (f3 INT); +CREATE TABLE IF NOT EXISTS t4 (f4 INT); +CREATE TABLE IF NOT EXISTS t5 (f5 INT); +CREATE TABLE IF NOT EXISTS t6 (f6 INT); +CREATE TABLE IF NOT EXISTS t7 (f7 INT); +CREATE TABLE IF NOT EXISTS t8 (f8 INT); +CREATE TABLE IF NOT EXISTS t9 (f9 INT); +CREATE TABLE IF NOT EXISTS t10 (f10 INT); +CREATE TABLE IF NOT EXISTS t11 (f11 INT); +CREATE TABLE IF NOT EXISTS t12 (f12 INT); +CREATE TABLE IF NOT EXISTS t13 (f13 INT); +CREATE TABLE IF NOT EXISTS t14 (f14 INT); +CREATE TABLE IF NOT EXISTS t15 (f15 INT); +CREATE TABLE IF NOT EXISTS t16 (f16 INT); +CREATE TABLE IF NOT EXISTS t17 (f17 INT); +CREATE TABLE IF NOT EXISTS t18 (f18 INT); +CREATE TABLE IF NOT EXISTS t19 (f19 INT); +CREATE TABLE IF NOT EXISTS t20 (f20 INT); +CREATE TABLE IF NOT EXISTS t21 (f21 INT); +CREATE TABLE IF NOT EXISTS t22 (f22 INT); +CREATE TABLE IF NOT EXISTS t23 (f23 INT); +CREATE TABLE IF NOT EXISTS t24 (f24 INT); +CREATE TABLE IF NOT EXISTS t25 (f25 INT); +CREATE TABLE IF NOT EXISTS t26 (f26 INT); +CREATE TABLE IF NOT EXISTS t27 (f27 INT); +CREATE TABLE IF NOT EXISTS t28 (f28 INT); +CREATE TABLE IF NOT EXISTS t29 (f29 INT); +CREATE TABLE IF NOT EXISTS t30 (f30 INT); +CREATE TABLE IF NOT EXISTS t31 (f31 INT); +CREATE TABLE IF NOT EXISTS t32 (f32 INT); +CREATE TABLE IF NOT EXISTS t33 (f33 INT); +CREATE TABLE IF NOT EXISTS t34 (f34 INT); +CREATE TABLE IF NOT EXISTS t35 (f35 INT); +CREATE TABLE IF NOT EXISTS t36 (f36 INT); +CREATE TABLE IF NOT EXISTS t37 (f37 INT); +CREATE TABLE IF NOT EXISTS t38 (f38 INT); +CREATE TABLE IF NOT EXISTS t39 (f39 INT); +CREATE TABLE IF NOT EXISTS t40 (f40 INT); +CREATE TABLE IF NOT EXISTS t41 (f41 INT); +CREATE TABLE IF NOT EXISTS t42 (f42 INT); +CREATE TABLE IF NOT EXISTS t43 (f43 INT); +CREATE TABLE IF NOT EXISTS t44 (f44 INT); +CREATE TABLE IF NOT EXISTS t45 (f45 INT); +CREATE TABLE IF NOT EXISTS t46 (f46 INT); +CREATE TABLE IF NOT EXISTS t47 (f47 INT); +CREATE TABLE IF NOT EXISTS t48 (f48 INT); +CREATE TABLE IF NOT EXISTS t49 (f49 INT); +CREATE TABLE IF NOT EXISTS t50 (f50 INT); +CREATE TABLE IF NOT EXISTS t51 (f51 INT); +CREATE TABLE IF NOT EXISTS t52 (f52 INT); +CREATE TABLE IF NOT EXISTS t53 (f53 INT); +CREATE TABLE IF NOT EXISTS t54 (f54 INT); +CREATE TABLE IF NOT EXISTS t55 (f55 INT); +CREATE TABLE IF NOT EXISTS t56 (f56 INT); +CREATE TABLE IF NOT EXISTS t57 (f57 INT); +CREATE TABLE IF NOT EXISTS t58 (f58 INT); +CREATE TABLE IF NOT EXISTS t59 (f59 INT); +CREATE TABLE IF NOT EXISTS t60 (f60 INT); +CREATE OR REPLACE VIEW v60 AS SELECT * FROM t60; + +EXPLAIN + SELECT t0.* +FROM t0 +JOIN t1 + ON t1.f1 = t0.f0 +LEFT JOIN t2 + ON t0.f0 = t2.f2 +LEFT JOIN t3 + ON t0.f0 = t3.f3 +LEFT JOIN t4 + ON t0.f0 = t4.f4 +LEFT JOIN t5 + ON t4.f4 = t5.f5 +LEFT JOIN t6 + ON t0.f0 = t6.f6 +LEFT JOIN t7 + ON t0.f0 = t7.f7 +LEFT JOIN t8 + ON t0.f0 = t8.f8 +LEFT JOIN t9 + ON t0.f0 = t9.f9 +LEFT JOIN t10 + ON t0.f0 = t10.f10 +LEFT JOIN t11 + ON t0.f0 = t11.f11 +LEFT JOIN t12 + ON t0.f0 = t12.f12 +LEFT JOIN t13 + ON t0.f0 = t13.f13 +LEFT JOIN t14 + ON t0.f0 = t14.f14 +LEFT JOIN t15 + ON t0.f0 = t15.f15 +LEFT JOIN t16 + ON t0.f0 = t16.f16 +LEFT JOIN t17 + ON t0.f0 = t17.f17 +LEFT JOIN t18 + ON t0.f0 = t18.f18 +LEFT JOIN t19 + ON t18.f18 = t19.f19 +LEFT JOIN t20 + ON t20.f20 = t19.f19 +LEFT JOIN t21 + ON t20.f20 = t21.f21 +LEFT JOIN t22 + ON t19.f19 = t22.f22 +LEFT JOIN t23 + ON t23.f23 = t0.f0 +LEFT JOIN t24 + ON t24.f24 = t23.f23 +LEFT JOIN t25 + ON t0.f0 = t25.f25 +LEFT JOIN t26 + ON t26.f26 = t0.f0 +LEFT JOIN t27 + ON t27.f27 = t0.f0 +LEFT JOIN t28 + ON t0.f0 = t28.f28 +LEFT JOIN t29 + ON t0.f0 = t29.f29 +LEFT JOIN t30 + ON t30.f30 = t0.f0 +LEFT JOIN t31 + ON t0.f0 = t31.f31 +LEFT JOIN t32 + ON t32.f32 = t31.f31 +LEFT JOIN t33 + ON t33.f33 = t0.f0 +LEFT JOIN t34 + ON t33.f33 = t34.f34 +LEFT JOIN t35 + ON t33.f33 = t35.f35 +LEFT JOIN t36 + ON t36.f36 = t0.f0 +LEFT JOIN t37 + ON t32.f32 = t37.f37 +LEFT JOIN t38 + ON t31.f31 = t38.f38 +LEFT JOIN t39 + ON t39.f39 = t0.f0 +LEFT JOIN t40 + ON t40.f40 = t39.f39 +LEFT JOIN t41 + ON t41.f41 = t0.f0 +LEFT JOIN t42 + ON t42.f42 = t41.f41 +LEFT JOIN t43 + ON t43.f43 = t41.f41 +LEFT JOIN t44 + ON t44.f44 = t0.f0 +LEFT JOIN t45 + ON t45.f45 = t0.f0 +LEFT JOIN t46 + ON t46.f46 = t0.f0 +LEFT JOIN t47 + ON t47.f47 = t0.f0 +LEFT JOIN t48 + ON t48.f48 = t0.f0 +LEFT JOIN t49 + ON t0.f0 = t49.f49 +LEFT JOIN t50 + ON t0.f0 = t50.f50 +LEFT JOIN t51 + ON t0.f0 = t51.f51 +LEFT JOIN t52 + ON t52.f52 = t0.f0 +LEFT JOIN t53 + ON t53.f53 = t0.f0 +LEFT JOIN t54 + ON t54.f54 = t0.f0 +LEFT JOIN t55 + ON t55.f55 = t0.f0 +LEFT JOIN t56 + ON t56.f56 = t0.f0 +LEFT JOIN t57 + ON t57.f57 = t0.f0 +LEFT JOIN t58 + ON t58.f58 = t57.f57 +LEFT JOIN t59 + ON t36.f36 = t59.f59 +LEFT JOIN v60 + ON t36.f36 = v60.f60 +; +drop table t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, +t10, t11, t12, t13, t14, t15, t16, t17, t18, +t19, t20, t21, t22, t23, t24, t25, t26, t27, +t28, t29, t30, t31, t32, t33, t34, t35, t36, +t37, t38, t39, t40, t41, t42, t43, t44, t45, +t46, t47, t48, t49, t50, t51, t52, t53, t54, +t55, t56, t57, t58, t59,t60; +drop view v60; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index 34639ef321f991d3b54027ec26f6cf0c72a6f8cb..9b00579944c7ccd7c069bdb0b2bdc4dfe103b516 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -23,70 +23,82 @@ # ############################################################################## +# Based on 10.1 c22ab56f0d690feee471e173a3d95acb642cd6dc + +main.alter_table : Modified in 10.1.34 main.alter_table_trans : MDEV-12084 - timeout main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result +main.assign_key_cache : Added in 10.1.34 +main.assign_key_cache_debug : Added in 10.1.34 main.auth_named_pipe : MDEV-14724 - System error 2 -main.create : Modified in 10.1.31 +main.connect : Modified in 10.1.33 +main.connect_debug : Added in 10.1.33 main.create_delayed : MDEV-10605 - failed with timeout +main.create_or_replace : Modified in 10.1.34 +main.ctype_ucs : Modified in 10.1.33 main.ctype_utf16le : MDEV-10675: timeout or extra warnings -main.ctype_utf8 : Modified in 10.1.30 -main.ctype_utf8mb4 : Modified in 10.1.30 -main.derived : Modified in 10.1.31 -main.dyncol : Modified in 10.1.31 +main.ctype_utf8mb4 : Modified in 10.1.33 +main.grant : Modified in 10.1.34 +main.grant_not_windows : Added in 10.1.34 main.events_2 : MDEV-13277 - Server crash main.events_bugs : MDEV-12892 - Crash in fill_schema_processlist +main.events_slowlog : MDEV-12821 - Wrong result main.events_restart : MDEV-12236 - Server shutdown problem -main.fulltext : Modified in 10.1.31 -main.func_concat : Modified in 10.1.31 -main.func_isnull : Modified in 10.1.31 -main.func_set : Modified in 10.1.30 -main.func_str : Modified in 10.1.30 -main.group_by : Modified in 10.1.30 -main.having : Modified in 10.1.30 +main.func_misc : Modified in 10.1.33 +main.func_str : Modified in 10.1.33 main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown main.index_intersect_innodb : MDEV-10643 - failed with timeout main.index_merge_innodb : MDEV-7142 - Wrong execution plan, timeout with valgrind main.innodb_mysql_lock : MDEV-7861 - sporadic lock detection failure -main.join_cache : Modified in 10.1.31 -main.join_outer : Modified in 10.1.30 +main.insert_select : Modified in 10.1.34 main.kill_processlist-6619 : MDEV-10793 - wrong result in processlist -main.mdev_14586 : Added in 10.1.31 +main.limit : Modified in 10.1.34 main.mdev-504 : MDEV-10607 - sporadic "can't connect" -main.mdev375 : MDEV-10607 - sporadic "can't connect" -main.merge : MDEV-10607 - sporadic "can't connect"; modified in 10.1.31 -main.myisam_optimize : Modified in 10.1.31 +main.mdev375 : MDEV-10607 - sporadic "can't connect"; modified in 10.1.33 +main.merge : MDEV-10607 - sporadic "can't connect" +main.myisam : Modified in 10.1.34 +main.myisam_recover : Modified in 10.1.33 +main.mysql : Modified in 10.1.34 main.mysql_client_test_nonblock : MDEV-15096 - exec failed +main.mysql_cp932 : Modified in 10.1.34 main.mysql_upgrade_noengine : MDEV-14355 - Plugin is busy -main.mysqldump-nl : Modified in 10.1.31 -main.mysqlslap : MDEV-11801 - timeout +main.mysqldump : Modified in 10.1.34 +main.mysqlslap : MDEV-11801 - timeout; modified in 10.1.34 main.mysqltest : MDEV-9269 - fails on Alpha -main.order_by : Modified in 10.1.31 +main.olap : Modified in 10.1.34 main.order_by_optimizer_innodb : MDEV-10683 - wrong execution plan -main.partition : Modified in 10.1.31 +main.parser : Modified in 10.1.33 +main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings -main.ps : MDEV-11017 - sporadic wrong Prepared_stmt_count; modified in 10.1.31 +main.ps : MDEV-11017 - sporadic wrong Prepared_stmt_count; modified in 10.1.34 main.query_cache : MDEV-12895 - Wrong result -main.query_cache_debug : Modified in 10.1.31 -main.range_vs_index_merge_innodb : MDEV-12637 - Timeout -main.repair : Modified in 10.1.31 +main.query_cache_debug : MDEV-15281 - Resize or similar command in progress +main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away +main.read_only_innodb : Modified in 10.1.34 +main.rename : Modified in 10.1.34 +main.selectivity : Modified in 10.1.34 main.set_statement : MDEV-13183 - Wrong result main.show_explain : MDEV-10674 - sporadic failure -main.sp : Modified in 10.1.31 +main.sp : Modified in 10.1.34 +main.sp-destruct : Modified in 10.1.33 +main.sp-innodb : Modified in 10.1.33 main.sp-security : MDEV-10607 - sporadic "can't connect" +main.stat_tables_par_innodb : MDEV-14155 - Wrong rounding +main.statistics : Modified in 10.1.33 +main.statistics_close : Added in 10.1.34 main.status : MDEV-8510 - sporadic wrong result -main.subselect : Modified in 10.1.31 +main.subselect4 : Modified in 10.1.33 main.subselect_innodb : MDEV-10614 - sporadic wrong results +main.subselect_sj : Modified in 10.1.33 +main.subselect_sj2_mat : Modified in 10.1.34 main.symlink-aria-11902 : MDEV-15098 - error 40 from storage engine main.symlink-myisam-11902 : MDEV-15098 - error 40 from storage engine main.tc_heuristic_recover : MDEV-15200 - wrong error on mysqld_stub_cmd -main.trigger : Modified in 10.1.30 +main.trigger : Modified in 10.1.34 main.type_blob : MDEV-15195 - Wrong result main.type_datetime_hires : MDEV-10687 - timeout -main.union : Modified in 10.1.31 -main.update_innodb : Modified in 10.1.31 -main.view : Modified in 10.1.30 -main.xa : Modified in 10.1.31 -main.xml : Modified in 10.1.31 +main.variables : Modified in 10.1.33 +main.view : Modified in 10.1.33 #---------------------------------------------------------------- @@ -97,8 +109,7 @@ archive.mysqlhotcopy_archive : MDEV-14726 - Table is marked as crashed #---------------------------------------------------------------- binlog.binlog_commit_wait : MDEV-10150 - Error: too much time elapsed -binlog.binlog_flush_binlogs_delete_domain : MDEV-14431 - Wrong error code; added in 10.1.30 -binlog.binlog_gtid_delete_domain_debug : Added in 10.1.30 +binlog.binlog_flush_binlogs_delete_domain : MDEV-14431 - Wrong error code binlog.binlog_killed : MDEV-12925 - Wrong result binlog.binlog_xa_recover : MDEV-8517 - Extra checkpoint @@ -114,28 +125,48 @@ binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL serve #---------------------------------------------------------------- +connect.jdbc : Included file modified in 10.1.33 +connect.jdbc_new : Included file modified in 10.1.33 +connect.jdbc_oracle : Included file modified in 10.1.33 +connect.jdbc_postgresql : Modified in 10.1.33 +connect.json_java_2 : Included file modified in 10.1.33 +connect.json_java_3 : Included file modified in 10.1.33 +connect.json_mongo_c : Included file modified in 10.1.33 +connect.json_udf : Modified in 10.1.33 +connect.mongo_c : Included file modified in 10.1.33 +connect.mongo_java_2 : Included file modified in 10.1.33 +connect.mongo_java_3 : Included file modified in 10.1.33 +connect.mongo_test : Modified in 10.1.33 connect.pivot : MDEV-14803 - failed to discover table +connect.tbl_thread : Modified in 10.1.33 +connect.vcol : Added in 10.1.33 connect.zip : MDEV-13884 - Wrong result #---------------------------------------------------------------- -encryption.create_or_replace : MDEV-9359 - Assertion failure, MDEV-13516 - Assertion failure -encryption.debug_key_management : MDEV-13841 - Timeout on wait condition; modified in 10.1.31 -encryption.encrypt_and_grep : MDEV-13765 - Wrong result; modified in 10.1.31 -encryption.innodb-bad-key-change2 : MDEV-12632 - Valgrind warnings -encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate -encryption.innodb-discard-import-change : MDEV-12632 - Valgrind warnings -encryption.innodb_encryption : Modified in 10.1.31 -encryption.innodb_encryption_discard_import : MDEV-12903 - Wrong result -encryption.innodb_encryption_filekeys : MDEV-9962 - timeouts +encryption.create_or_replace : MDEV-16115 - Trying to access tablespace +encryption.debug_key_management : MDEV-13841 - Timeout on wait condition +encryption.encrypt_and_grep : MDEV-13765 - Wrong result +encryption.innodb-bad-key-change : Modified in 10.1.34 +encryption.innodb-bad-key-change2 : Modified in 10.1.34 +encryption.innodb-bad-key-change4 : Modified in 10.1.34 +encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate; modified in 10.1.34 +encryption.innodb-discard-import : Modified in 10.1.34 +encryption.innodb-encryption-disable : Modified in 10.1.34 +encryption.innodb_encryption_discard_import : MDEV-16116 - Wrong result; modified in 10.1.33 +encryption.innodb_encryption_filekeys : Modified in 10.1.33 encryption.innodb_encryption-page-compression : MDEV-12630 - crash or assertion failure -encryption.innodb_encryption_tables : MDEV-9359 - Assertion failure -encryption.innodb_first_page : MDEV-10689 - crashes +encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash +encryption.innodb_first_page : MDEV-10689 - Crash encryption.innodb-first-page-read : MDEV-14356 - Timeout on wait condition -encryption.innodb_lotoftables : MDEV-11531 - InnoDB error -encryption.innodb-missing-key : MDEV-9359 - assertion failure +encryption.innodb-force-corrupt : Modified in 10.1.34 +encryption.innodb_lotoftables : MDEV-16111 - Wrong result +encryption.innodb-missing-key : Modified in 10.1.34 encryption.innodb-page_encryption : MDEV-10641 - mutex problem -encryption.innodb-redo-badkey : MDEV-12898 - Server hang on startup +encryption.innodb-read-only : MDEV-14728 - Unable to get certificate +encryption.innodb-redo-badkey : MDEV-12898 - Server hang on startup; modified in 10.1.34 +encryption.innodb-redo-nokeys : Modified in 10.1.34 +encryption.innodb-remove-encryption : MDEV-16493 - Timeout in wait condition; a dded in 10.1.33 encryption.innodb_scrub : MDEV-8139 - scrubbing tests need fixing encryption.innodb_scrub_background : MDEV-8139 - scrubbing tests need fixing encryption.innodb_scrub_compressed : MDEV-8139 - scrubbing tests need fixing @@ -152,7 +183,6 @@ federated.federated_innodb : MDEV-10617, MDEV-10417 - Wrong checksum, time federated.federated_partition : MDEV-10417 - Fails on Mips federated.federated_transactions : MDEV-10617, MDEV-10417 - Wrong checksum, timeouts, fails on Mips federated.federatedx : MDEV-10617 - Wrong checksum, timeouts -federated.net_thd_crash-12951 : Added in 10.1.31 #---------------------------------------------------------------- @@ -181,48 +211,60 @@ galera.MW-328A : MDEV-13876 - Wrong result #---------------------------------------------------------------- +handler.ps : Added in 10.1.34 + +#---------------------------------------------------------------- + +innodb.alter_partitioned_xa : Added in 10.1.33 innodb.binlog_consistent : MDEV-10618 - Server fails to start innodb.doublewrite : MDEV-12905 - Lost connection to MySQL server -innodb_fts.fulltext2 : MDEV-14727 - Long semaphore wait -innodb.innodb : Opt file modified in 10.1.31 innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup +innodb.innodb-alter : Added in 10.1.34 innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS +innodb.innodb-alter-nullable : Modified in 10.1.33 innodb.innodb-alter-table : MDEV-10619 - Testcase timeout -innodb.innodb-autoinc : Modified in 10.1.30 -innodb.innodb-blob : MDEV-12053 - Client crash +innodb.innodb-blob : MDEV-12053 - Client crash; modified in 10.1.34 innodb.innodb_bug14147491 : MDEV-11808 - wrong error codes innodb.innodb_bug30423 : MDEV-7311 - Wrong number of rows in the plan innodb.innodb_bug48024 : MDEV-14352 - Assertion failure -innodb.innodb_corrupt_bit : Modified in 10.1.31 +innodb.innodb_bug54044 : Modified in 10.1.34 +innodb.innodb_defragment_small : Modified in 10.1.34 innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown -innodb.innodb-index-online : Modified in 10.1.31 -innodb.innodb-lru-force-no-free-page : Added in 10.1.31 innodb.innodb_max_recordsize_64k : MDEV-15203 - wrong result +innodb.innodb-mdev7046 : Modified in 10.1.34 +innodb.innodb-page_compression_default : Modified in 10.1.34 innodb.innodb-page_compression_lzma : MDEV-14353 - wrong result on Fedora 25 +innodb.innodb-page_compression_snappy : Modified in 10.1.34 innodb.innodb-page_compression_zip : MDEV-10641 - mutex problem -innodb.innodb-replace-debug : Modified in 10.1.31 innodb.innodb_stats : MDEV-10682 - wrong result innodb.innodb_sys_semaphore_waits : MDEV-10331 - wrong result innodb.innodb_zip_innochecksum2 : MDEV-13882 - Warning: difficult to find free blocks -innodb.log_file_size : MDEV-15202 - Cannot resize log files in read-only mode -innodb.recovery_shutdown : Added in 10.1.30 +innodb.lock_deleted : Added in 10.1.34 +innodb.log_file_size : MDEV-15668 - Not found pattern +innodb.recovery_shutdown : MDEV-15671 - Warning: database page corruption +innodb.rename_table : Added in 10.1.34 innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace -innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; opt file modified in 10.1.31 +innodb.table_definition_cache_debug : MDEV-14206 - Extra warning innodb.table_flags : MDEV-14363 - Operating system error number 2 -innodb_fts.fulltext_misc : MDEV-12636 - Valgrind warnings +#---------------------------------------------------------------- + +innodb_fts.basic : Added in 10.1.34 #---------------------------------------------------------------- -maria.lock : Modified in 10.1.31 -maria.maria : MDEV-14430 - Wrong result; modified in 10.1.31 -maria.repair : Added in 10.1.31 +maria.alter : Modified in 10.1.34 +maria.insert_select : MDEV-12757 - Timeout +maria.insert_select-7314 : MDEV-16492 - Timeout +maria.lock : Modified in 10.1.34 +maria.maria : MDEV-14430 - Wrong result; modified in 10.1.34 #---------------------------------------------------------------- -mariabackup.huge_lsn : Added in 10.1.31 -mariabackup.mdev-14447 : MDEV-15201 - Timeout; added in 10.1.30 -mariabackup.missing_ibd : Added in 10.1.31 +mariabackup.absolute_ibdata_paths : Added in 10.1.33 +mariabackup.backup_ssl : Added in 10.1.34 +mariabackup.incremental_encrypted : MDEV-15667 - Timeout +mariabackup.mdev-14447 : MDEV-15201 - Timeout mariabackup.xb_compressed_encrypted : MDEV-14812 - Segfault #---------------------------------------------------------------- @@ -235,12 +277,6 @@ mroonga/storage.index_multiple_column_unique_date_32bit_equal : Wrong resul mroonga/storage.index_multiple_column_unique_date_order_32bit_desc : Wrong result on Alpha mroonga/storage.index_multiple_column_unique_datetime_index_read : MDEV-8643 - valgrind warnings mroonga/storage.repair_table_no_index_file : MDEV-9364 - wrong result, MDEV-14807 - wrong error message -mroonga/storage.variable_query_log_file_disabled_empty_value : Modified in 10.1.30 -mroonga/storage.variable_query_log_file_disabled_null_value : Modified in 10.1.30 -mroonga/storage.variable_query_log_file_enabled_empty_value : Modified in 10.1.30 -mroonga/storage.variable_query_log_file_enabled_null_value : Modified in 10.1.30 -mroonga/storage.variable_query_log_file_new_value : Modified in 10.1.30 -mroonga/storage.variable_query_log_file_same_value : Modified in 10.1.30 mroonga/wrapper.repair_table_no_index_file : MDEV-14807 - Wrong error message @@ -255,10 +291,11 @@ multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_h #---------------------------------------------------------------- -parts.partition_alter_innodb : Added in 10.1.30 -parts.partition_alter_maria : Modified in 10.1.30 -parts.partition_alter_myisam : Modified in 10.1.31 +parts.partition_alter_innodb : Include file modified in 10.1.33 +parts.partition_alter_maria : Include file modified in 10.1.33 +parts.partition_alter_myisam : Include file modified in 10.1.33 parts.partition_alter2_2_maria : MDEV-14364 - Lost connection to MySQL server during query +parts.partition_auto_increment_archive : MDEV-16491 - Table marked as crashed parts.partition_auto_increment_maria : MDEV-14430 - Wrong result parts.partition_debug_innodb : MDEV-15095 - table does not exist parts.partition_innodb_status_file : MDEV-12901 - Valgrind @@ -267,9 +304,10 @@ parts.partition_innodb_status_file : MDEV-12901 - Valgrind perfschema.func_file_io : MDEV-5708 - fails for s390x perfschema.func_mutex : MDEV-5708 - fails for s390x -perfschema.misc : Modified in 10.1.30 +perfschema.hostcache_ipv4_max_con : Modified in 10.1.33 +perfschema.hostcache_ipv6_max_con : Modified in 10.1.33 +perfschema.partition : Added in 10.1.34 perfschema.privilege_table_io : MDEV-13184 - Extra lines -perfschema.setup_actors : MDEV-10679 - rare crash perfschema.socket_summary_by_event_name_func : MDEV-10622 - Socket summary tables do not match perfschema.stage_mdl_global : MDEV-11803 - wrong result on slow builders perfschema.stage_mdl_table : MDEV-12638 - Wrong result @@ -277,29 +315,26 @@ perfschema.threads_mysql : MDEV-10677 - sporadic wrong resul #---------------------------------------------------------------- -plugins.binlog-simple_plugin_check : Added in 10.1.30 plugins.feedback_plugin_send : MDEV-7932 - ssl failed for url -plugins.server_audit : MDEV-9562 - crashes on sol10-sparc +plugins.processlist : Added in 10.1.34 +plugins.server_audit : MDEV-9562 - crashes on sol10-sparc; modified in 10.1.34 plugins.thread_pool_server_audit : MDEV-9562 - crashes on sol10-sparc #---------------------------------------------------------------- -roles.flush_roles-12366 : Added in 10.1.30 -roles.set_role-13655 : Added in 10.1.30 - -#---------------------------------------------------------------- - rpl.last_insert_id : MDEV-10625 - warnings in error log +rpl.rename : Added in 10.1.34 rpl.rpl_auto_increment : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_bug45679 : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log rpl.rpl_binlog_index : MDEV-9501 - Warning: failed registering on master +rpl.rpl_colSize : MDEV-16112 - Server crash rpl.rpl_ddl : MDEV-10417 - Fails on Mips rpl.rpl_domain_id_filter_io_crash : MDEV-14357 - Wrong result rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result rpl.rpl_gtid_basic : MDEV-10681 - server startup problem rpl.rpl_gtid_crash : MDEV-9501 - Warning: failed registering on master -rpl.rpl_gtid_delete_domain : MDEV-14463 - Timeout in include; added in 10.1.30 +rpl.rpl_gtid_delete_domain : MDEV-14463 - Timeout in include rpl.rpl_gtid_mdev9033 : MDEV-10680 - warnings rpl.rpl_gtid_reconnect : MDEV-14497 - Timeout rpl.rpl_gtid_stop_start : MDEV-10629 - Crash on shutdown, MDEV-12629 - Valgrind warnings @@ -310,29 +345,27 @@ rpl.rpl_insert_delayed : MDEV-9329 - Fails on Ubuntu/s390x rpl.rpl_insert_id : MDEV-15197 - Wrong result rpl.rpl_insert_ignore : MDEV-14365 - Lost connection to MySQL server during query rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips -rpl.rpl_manual_change_index_file : Modified in 10.1.31 rpl.rpl_mariadb_slave_capability : MDEV-11018 - sporadic wrong events in binlog -rpl.rpl_mdev6020 : MDEV-10630, MDEV-10417 - Timeouts, fails on Mips +rpl.rpl_mdev6020 : MDEV-10417 - Fails on Mips +rpl.rpl_mixed_implicit_commit_binlog : Modified in 10.1.34 rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed -rpl.rpl_non_direct_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_parallel : MDEV-10653 - Timeouts rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure rpl.rpl_parallel_multilevel2 : MDEV-14723 - Timeout -rpl.rpl_parallel_optimistic : MDEV-10511 - Timeout +rpl.rpl_parallel_optimistic : MDEV-10511 - Timeout; modified in 10.1.34 rpl.rpl_parallel_retry : MDEV-11119 - Server crash rpl.rpl_parallel_temptable : MDEV-10356 - Crash in close_thread_tables rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips rpl.rpl_password_boundaries : MDEV-11534 - Slave IO warnings +rpl.rpl_row_basic_2myisam : MDEV-13875 - command "diff_files" failed rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result rpl.rpl_row_img_blobs : MDEV-13875 - command "diff_files" failed rpl.rpl_row_img_eng_min : MDEV-13875 - command "diff_files" failed rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed +rpl.rpl_row_implicit_commit_binlog : Modified in 10.1.34 rpl.rpl_row_index_choice : MDEV-15196 - Slave crash -rpl.rpl_row_log : Include file modified in 10.1.30 -rpl.rpl_row_log_innodb : Include file modified in 10.1.30 -rpl.rpl_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x rpl.rpl_semi_sync : MDEV-11220 - Wrong result rpl.rpl_semi_sync_after_sync : MDEV-14366 - Wrong result @@ -344,7 +377,7 @@ rpl.rpl_show_slave_hosts : MDEV-10681 - server startup problem rpl.rpl_skip_replication : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha rpl.rpl_slave_grp_exec : MDEV-10514 - Unexpected deadlock rpl.rpl_start_stop_slave : MDEV-13567 - Replication failure -rpl.rpl_stm_log : Include file modified in 10.1.30 +rpl.rpl_stm_implicit_commit_binlog : Modified in 10.1.34 rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion rpl.rpl_sync : MDEV-10633 - Database page corruption @@ -355,16 +388,11 @@ rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result spider.* : MDEV-9329 - tests are too memory-consuming -spider.spider_fixes : MDEV-12900 - Valgrind -spider.spider_fixes_part : MDEV-12900 - Valgrind - -spider/bg.basic_sql : MDEV-12900 - Valgrind spider/bg.direct_aggregate : MDEV-7098 - Trying to unlock mutex that wasn't locked spider/bg.direct_aggregate_part : MDEV-7098 - Trying to unlock mutex that wasn't locked -spider/bg.function : MDEV-12900 - Valgrind -spider/bg.ha : MDEV-7914 - Crash, MDEV-9329 - failures on s390x -spider/bg.ha_part : MDEV-7914 - Crash, MDEV-9329 - Fails on Ubuntu/s390x -spider/bg.spider_fixes : MDEV-7098 -Mutex problem, MDEV-9329 - failures on s390x, MDEV-12900 - Valgrind +spider/bg.ha : MDEV-9329 - failures on s390x +spider/bg.ha_part : MDEV-9329 - Fails on Ubuntu/s390x +spider/bg.spider_fixes : MDEV-7098 -Mutex problem, MDEV-9329 - failures on s390x spider/bg.spider3_fixes : MDEV-12639 - Packets out of order spider/bg.vp_fixes : MDEV-9329 - Fails on Ubuntu/s390x @@ -386,16 +414,17 @@ stress.ddl_innodb : MDEV-10635 - Testcase timeout sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout -sys_vars.innodb_fatal_semaphore_wait_threshold : MDEV-10513 - crashes -sys_vars.innodb_print_lock_wait_timeout_info_basic : Added in 10.1.31 sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash +sys_vars.max_prepared_stmt_count_basic : Modified in 10.1.33 sys_vars.rpl_init_slave_func : MDEV-10149 - wrong results +sys_vars.sysvars_innodb : Opt file modified in 10.1.33 +sys_vars.sysvars_server_embedded : Opt file added in 10.1.33 +sys_vars.sysvars_server_notembedded : Opt file added in 10.1.33 sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result sys_vars.wait_timeout_func : MDEV-12896 - Wrong result #---------------------------------------------------------------- -tokudb.card_scale_percent : Modified in 10.1.31 tokudb.change_column_all_1000_10 : MDEV-12640 - Crash tokudb.change_column_bin : MDEV-12640 - Crash tokudb.change_column_char : MDEV-12822 - Lost connection to MySQL server @@ -405,35 +434,25 @@ tokudb.cluster_filter_unpack_varchar : MDEV-10636 - Wrong execution plan tokudb.dir_per_db : MDEV-11537 - Wrong result tokudb.dir_per_db_rename_to_nonexisting_schema : MDEV-14359 - Directory not empty tokudb.hotindex-insert-bigchar : MDEV-12640 - Crash +tokudb.hotindex-insert-0 : MDEV-15271 - Timeout tokudb.hotindex-insert-1 : MDEV-13870 - Lost connection to MySQL server tokudb.hotindex-update-0 : MDEV-15198 - Timeout tokudb.hotindex-update-1 : MDEV-12640 - Crash -tokudb.locking-read-repeatable-read-1 : Added in 10.1.31 -tokudb.locking-read-repeatable-read-2 : Added in 10.1.31 -tokudb.nonflushing_analyze_debug : Added in 10.1.31 -tokudb.row_format : Modified in 10.1.31 tokudb.rows-32m-rand-insert : MDEV-12640 - Crash tokudb.rows-32m-seq-insert : MDEV-12640 - Crash +tokudb.savepoint-5 : MDEV-15280 - Wrong result tokudb.type_datetime : MDEV-15193 - Wrong result tokudb_bugs.checkpoint_lock : MDEV-10637 - Wrong processlist output tokudb_bugs.checkpoint_lock_3 : MDEV-10637 - Wrong processlist output +tokudb_bugs.db917 : Modified in 10.1.33 tokudb_bugs.xa : MDEV-11804 - Lock wait timeout -tokudb_mariadb.mdev6657 : MDEV-12737 - Wrong plan, valgrind warnings - -tokudb_parts.nonflushing_analyze_debug : Added in 10.1.31 - -tokudb_perfschema.crash_tokudb : Added in 10.1.31 -tokudb_perfschema.start_server_tokudb : Added in 10.1.31 - -rpl-tokudb.rpl_tokudb_row_log : Include file modified in 10.1.30 -rpl-tokudb.rpl_tokudb_stm_log : Include file modified in 10.1.30 - #---------------------------------------------------------------- unit.lf : MDEV-12897 - Signal 11 thrown unit.ma_test_loghandler : MDEV-10638 - record read not ok +unit.my_atomic : MDEV-15670 - Signal 11 thrown #---------------------------------------------------------------- @@ -446,5 +465,6 @@ wsrep.binlog_format : MDEV-11532 - WSREP has not yet prepared node wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node wsrep.mdev_6832 : MDEV-14195 - Failure upon check-testcase wsrep.pool_of_threads : MDEV-12234 - Library problem on Power +wsrep.variables : Modified in 10.1.34 wsrep_info.plugin : MDEV-12909 - Wrong result diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 7354b1699b1f96e47ec6bd971a3857c40be24583..5e407e9caece59acdb0459a9ac44d567ca8ad729 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -1,5 +1,5 @@ -/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB +/* Copyright (c) 2006, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 @@ -102,8 +102,8 @@ static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, do { /* PTR() isn't necessary below, head is a dummy node */ cursor->curr= (LF_SLIST *)(*cursor->prev); lf_pin(pins, 1, cursor->curr); - } while (*cursor->prev != (intptr)cursor->curr && LF_BACKOFF); - + } while (my_atomic_loadptr((void**)cursor->prev) != cursor->curr && + LF_BACKOFF); for (;;) { if (unlikely(!cursor->curr)) diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 1c5a4152292a8b91397375a09ad98914c1f77d28..53edfc5d87be8474f4846084da1f0437d81f1c04 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -3833,7 +3833,7 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str, for (i= 0; i < len; i++) { register char c= append[i]; - if (unlikely(c <= 0x1F)) + if (unlikely(((uchar)c) <= 0x1F)) { if (lim < 5) { diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a0ddc3e40a5bb9188a603d5e8cc633c5207c4260..56b1ae3fc6e5be894bbe1601c696204219781cf2 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -440,7 +440,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, info->read_end= info->buffer; _my_b_encr_read(info, 0, 0); /* prefill the buffer */ info->write_pos= info->read_pos; - info->pos_in_file+= info->buffer_length; + info->seek_not_done=1; } } else diff --git a/mysys/my_addr_resolve.c b/mysys/my_addr_resolve.c index 82043dc03fed8553634fb3682d9151616074f2fd..b82792fc4b5b10def60d224fddbb8e02b42fb90e 100644 --- a/mysys/my_addr_resolve.c +++ b/mysys/my_addr_resolve.c @@ -214,7 +214,7 @@ int my_addr_resolve(void *ptr, my_addr_loc *loc) strnmov(addr2line_binary, info.dli_fname, sizeof(addr2line_binary)); } offset = info.dli_fbase; - len= my_snprintf(input, sizeof(input), "%p\n", ptr - offset); + len= my_snprintf(input, sizeof(input), "%08x\n", (ulonglong)(ptr - offset)); if (write(in[1], input, len) <= 0) return 1; diff --git a/mysys/my_default.c b/mysys/my_default.c index 2358aed8f3bed201cbb8b4839494ec35cd00b6f3..5c4e33141a62673442d7899ba23ca5ba1f7e0415 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -631,7 +631,7 @@ int my_load_defaults(const char *conf_file, const char **groups, if (!my_getopt_is_args_separator((*argv)[i])) /* skip arguments separator */ printf("%s ", (*argv)[i]); puts(""); - exit(0); + DBUG_RETURN(4); } if (default_directories) @@ -641,7 +641,7 @@ int my_load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); - return 2; + DBUG_RETURN(2); } @@ -1099,10 +1099,12 @@ void print_defaults(const char *conf_file, const char **groups) } } puts("\nThe following options may be given as the first argument:\n\ ---print-defaults Print the program argument list and exit.\n\ ---no-defaults Don't read default options from any option file.\n\ ---defaults-file=# Only read default options from the given file #.\n\ ---defaults-extra-file=# Read this file after the global files are read."); +--print-defaults Print the program argument list and exit.\n\ +--no-defaults Don't read default options from any option file.\n\ +The following specify which files/extra groups are read (specified before remaining options):\n\ +--defaults-file=# Only read default options from the given file #.\n\ +--defaults-extra-file=# Read this file after the global files are read.\n\ +--defaults-group-suffix=# Additionally read default groups with # appended as a suffix."); } diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index 06f6a29e4a0004c2888f880f8f1a3c6ab3732f5e..8580fac3595c5d6fad6c5064fd7a5aec80696ead 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -244,7 +244,7 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd) return pathname + (s - buf); } - fd = openat(dfd, s, O_NOFOLLOW | O_PATH); + fd = openat(dfd, s, O_NOFOLLOW | O_PATH | O_CLOEXEC); if (fd < 0) goto err; diff --git a/pcre/AUTHORS b/pcre/AUTHORS index 291657caef10a10c4cd89871b7e666e5979ea47c..eb9b1a44b34a62cde8ca6188812fd9253780faa7 100644 --- a/pcre/AUTHORS +++ b/pcre/AUTHORS @@ -8,7 +8,7 @@ Email domain: cam.ac.uk University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2017 University of Cambridge +Copyright (c) 1997-2018 University of Cambridge All rights reserved @@ -19,7 +19,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2017 Zoltan Herczeg +Copyright(c) 2010-2018 Zoltan Herczeg All rights reserved. @@ -30,7 +30,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2017 Zoltan Herczeg +Copyright(c) 2009-2018 Zoltan Herczeg All rights reserved. diff --git a/pcre/ChangeLog b/pcre/ChangeLog index 590a7542885b3c4f5118de1fdfc500d43a600518..7b53195f6a6365716b9ae9811eb0253b3566a6c6 100644 --- a/pcre/ChangeLog +++ b/pcre/ChangeLog @@ -4,6 +4,59 @@ ChangeLog for PCRE Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All development is happening in the PCRE2 10.xx series. + +Version 8.42 20-March-2018 +-------------------------- + +1. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard. + +2. Fixed outdated real_pcre definitions in pcre.h.in (patch by Evgeny Kotkov). + +3. pcregrep was truncating components of file names to 128 characters when +processing files with the -r option, and also (some very odd code) truncating +path names to 512 characters. There is now a check on the absolute length of +full path file names, which may be up to 2047 characters long. + +4. Using pcre_dfa_exec(), in UTF mode when UCP support was not defined, there +was the possibility of a false positive match when caselessly matching a "not +this character" item such as [^\x{1234}] (with a code point greater than 127) +because the "other case" variable was not being initialized. + +5. Although pcre_jit_exec checks whether the pattern is compiled +in a given mode, it was also expected that at least one mode is available. +This is fixed and pcre_jit_exec returns with PCRE_ERROR_JIT_BADOPTION +when the pattern is not optimized by JIT at all. + +6. The line number and related variables such as match counts in pcregrep +were all int variables, causing overflow when files with more than 2147483647 +lines were processed (assuming 32-bit ints). They have all been changed to +unsigned long ints. + +7. If a backreference with a minimum repeat count of zero was first in a +pattern, apart from assertions, an incorrect first matching character could be +recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set +as the first character of a match. + +8. Fix out-of-bounds read for partial matching of /./ against an empty string +when the newline type is CRLF. + +9. When matching using the the REG_STARTEND feature of the POSIX API with a +non-zero starting offset, unset capturing groups with lower numbers than a +group that did capture something were not being correctly returned as "unset" +(that is, with offset values of -1). + +10. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string +containing multi-code-unit characters caused bad behaviour and possibly a +crash. This issue was fixed for other kinds of repeat in release 8.37 by change +38, but repeating character classes were overlooked. + +11. A small fix to pcregrep to avoid compiler warnings for -Wformat-overflow=2. + +12. Added --enable-jit=auto support to configure.ac. + +13. Fix misleading error message in configure.ac. + + Version 8.41 05-July-2017 ------------------------- diff --git a/pcre/INSTALL b/pcre/INSTALL index 2099840756e6302d837dcd51b5dcd6262f7adb16..8865734f81b136629e961c230380423899c75794 100644 --- a/pcre/INSTALL +++ b/pcre/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, -Inc. + Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software +Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -12,97 +12,96 @@ without warranty of any kind. Basic Installation ================== - Briefly, the shell command `./configure && make && make install' + Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for +more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented +'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. - The `configure' shell script attempts to guess correct values for + The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that +those values to create a 'Makefile' in each directory of the package. +It may also create one or more '.h' files containing system-dependent +definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). +file 'config.log' containing compiler output (useful mainly for +debugging 'configure'). - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. + It can also use an optional file (typically called 'config.cache' and +enabled with '--cache-file=config.cache' or simply '-C') that saves the +results of its tests to speed up reconfiguring. Caching is disabled by +default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can +to figure out how 'configure' could check whether to do them, and mail +diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you +some point 'config.cache' contains results you don't want to keep, you may remove or edit it. - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. + The file 'configure.ac' (or 'configure.in') is used to create +'configure' by a program called 'autoconf'. You need 'configure.ac' if +you want to change it or regenerate 'configure' using a newer version of +'autoconf'. The simplest way to compile this package is: - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. + 1. 'cd' to the directory containing the package's source code and type + './configure' to configure the package for your system. - Running `configure' might take a while. While running, it prints + Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. - 2. Type `make' to compile the package. + 2. Type 'make' to compile the package. - 3. Optionally, type `make check' to run any self-tests that come with + 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. - 4. Type `make install' to install the programs and any data files and + 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root + user, and only the 'make install' phase executed with root privileges. - 5. Optionally, type `make installcheck' to repeat any self-tests, but + 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required + regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly + source code directory by typing 'make clean'. To also remove the + files that 'configure' created (so you can compile the package for + a different kind of computer), type 'make distclean'. There is + also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. - 7. Often, you can also type `make uninstall' to remove the installed + 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. - 8. Some packages, particularly those that use Automake, provide `make + 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. + targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' +the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: + You can give 'configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here is +an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix @@ -113,21 +112,21 @@ Compiling For Multiple Architectures You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the +own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. +the 'configure' script. 'configure' automatically checks for the source +code in the directory that 'configure' is in and in '..'. This is known +as a "VPATH" build. - With a non-GNU `make', it is safer to compile the package for one + With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before +installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like +"universal" binaries--by specifying multiple '-arch' options to the +compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ @@ -136,105 +135,104 @@ this: This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. +using the 'lipo' tool if you have problems. Installation Names ================== - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an + By default, 'make install' installs the package's commands under +'/usr/local/bin', include files under '/usr/local/include', etc. You +can specify an installation prefix other than '/usr/local' by giving +'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses +pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory +options like '--bindir=DIR' to specify different values for particular +kinds of files. Run 'configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the default +for these options is expressed in terms of '${prefix}', so that +specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or +correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without +'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each -affected directory. For example, `make install +affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and +'${prefix}'. Any directories that were specified during 'configure', +but not in terms of '${prefix}', must each be overridden at install time +for the entire installation to be relocated. The approach of makefile +variable overrides for each directory variable is required by the GNU +Coding Standards, and ideally causes no recompilation. However, some +platforms have known limitations with the semantics of shared libraries +that end up requiring recompilation when using this method, particularly +noticeable in packages that use GNU Libtool. + + The second method involves providing the 'DESTDIR' variable. For +example, 'make install DESTDIR=/alternate/directory' will prepend +'/alternate/directory' before all installation names. The approach of +'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. +when some directory options were not specified in terms of '${prefix}' +at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the +with an extra prefix or suffix on their names by giving 'configure' the +option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. + + Some packages pay attention to '--enable-FEATURE' options to +'configure', where FEATURE indicates an optional part of the package. +They may also pay attention to '--with-PACKAGE' options, where PACKAGE +is something like 'gnu-as' or 'x' (for the X Window System). The +'README' should mention any '--enable-' and '--with-' options that the package recognizes. - For packages that use the X Window System, `configure' can usually + For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. +you can use the 'configure' options '--x-includes=DIR' and +'--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure +execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure +overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. +overridden with 'make V=0'. Particular systems ================== - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in + On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC +is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. + HP-UX 'make' updates targets which have the same time stamps as their +prerequisites, which makes it generally unusable when shipped generated +files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try +parse its '' header file. The option '-nodtk' can be used as a +workaround. If GNU CC is not installed, it is therefore recommended to +try ./configure CC="cc" @@ -242,26 +240,26 @@ and if that doesn't work, try ./configure CC="cc -nodtk" - On Solaris, don't put `/usr/ucb' early in your `PATH'. This + On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. +these programs are available in '/usr/bin'. So, if you need '/usr/ucb' +in your 'PATH', put it _after_ '/usr/bin'. - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: + On Haiku, software installed for all users goes in '/boot/common', +not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== - There may be some features `configure' cannot figure out + There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints +_same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: +'--build=TYPE' option. TYPE can either be a short name for the system +type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM @@ -270,101 +268,101 @@ where SYSTEM can have one of these forms: OS KERNEL-OS - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't + See the file 'config.sub' for the possible values of each field. If +'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will +use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. +eventually be run) with '--host=TYPE'. Sharing Defaults ================ - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. + If you want to set default values for 'configure' scripts to share, +you can create a site shell script called 'config.site' that gives +default values for variables like 'CC', 'cache_file', and 'prefix'. +'configure' looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run +environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: +them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc -causes the specified `gcc' to be used as the C compiler (unless it is +causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: +Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an +Autoconf limitation. Until the limitation is lifted, you can use this +workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash -`configure' Invocation +'configure' Invocation ====================== - `configure' recognizes the following options to control how it + 'configure' recognizes the following options to control how it operates. -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. +'--help' +'-h' + Print a summary of all of the options to 'configure', and exit. -`--help=short' -`--help=recursive' +'--help=short' +'--help=recursive' Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. + 'configure', and exit. The 'short' variant lists options used only + in the top level, while the 'recursive' variant lists options also + present in any nested packages. -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' +'--version' +'-V' + Print the version of Autoconf used to generate the 'configure' script, and exit. -`--cache-file=FILE' +'--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to + traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. +'--config-cache' +'-C' + Alias for '--cache-file=config.cache'. -`--quiet' -`--silent' -`-q' +'--quiet' +'--silent' +'-q' Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error + suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). -`--srcdir=DIR' +'--srcdir=DIR' Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. + 'configure' can determine that directory automatically. -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. +'--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: for + more details, including other options available for fine-tuning the + installation locations. -`--no-create' -`-n' +'--no-create' +'-n' Run the configure checks, but stop before creating any output files. -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. +'configure' also accepts some other, not widely useful, options. Run +'configure --help' for more details. diff --git a/pcre/LICENCE b/pcre/LICENCE index dd9071a8dd8192f7d734352e29b9395da2ded229..f6ef7fd76649608d9d6f8a88c5e84d83a0cc946d 100644 --- a/pcre/LICENCE +++ b/pcre/LICENCE @@ -25,7 +25,7 @@ Email domain: cam.ac.uk University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2017 University of Cambridge +Copyright (c) 1997-2018 University of Cambridge All rights reserved. @@ -36,7 +36,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2017 Zoltan Herczeg +Copyright(c) 2010-2018 Zoltan Herczeg All rights reserved. @@ -47,7 +47,7 @@ Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2017 Zoltan Herczeg +Copyright(c) 2009-2018 Zoltan Herczeg All rights reserved. diff --git a/pcre/NEWS b/pcre/NEWS index 36be07cb8803147b2b427dd9d2e6c70e55607bda..09b4ad360037039ac37eb011639bd6d824eabfab 100644 --- a/pcre/NEWS +++ b/pcre/NEWS @@ -1,6 +1,12 @@ News about PCRE releases ------------------------ +Release 8.42 20-March-2018 +-------------------------- + +This is a bug-fix release. + + Release 8.41 13-June-2017 ------------------------- diff --git a/pcre/NON-AUTOTOOLS-BUILD b/pcre/NON-AUTOTOOLS-BUILD index 3910059106bd3a8c11ca75c2c02f25627de7b1ea..37f6164475b37ce190c62dce51d56e73fb11b499 100644 --- a/pcre/NON-AUTOTOOLS-BUILD +++ b/pcre/NON-AUTOTOOLS-BUILD @@ -760,13 +760,14 @@ The character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and applications can be supported through UNIX System Services, and in such an environment PCRE can be built in the same way as in other systems. However, in native z/OS (without UNIX System Services) and in z/VM, special ports are -required. For details, please see this web site: +required. PCRE1 version 8.39 is available in file 882 on this site: - http://www.zaconsultants.net + http://www.cbttape.org -You may download PCRE from WWW.CBTTAPE.ORG, file 882.  Everything, source and -executable, is in EBCDIC and native z/OS file formats and this is the -recommended download site. +Everything, source and executable, is in EBCDIC and native z/OS file formats. +However, this software is not maintained and will not be upgraded. If you are +new to PCRE you should be looking at PCRE2 (version 10.30 or later). -========================== -Last Updated: 25 June 2015 +=============================== +Last Updated: 13 September 2017 +=============================== diff --git a/pcre/configure.ac b/pcre/configure.ac index 718a18508c918b8094f27ca8eb83d3b61a5404b5..dcdef6a942796ed43745f6cec1801c849067ca1b 100644 --- a/pcre/configure.ac +++ b/pcre/configure.ac @@ -9,18 +9,18 @@ dnl The PCRE_PRERELEASE feature is for identifying release candidates. It might dnl be defined as -RC2, for example. For real releases, it should be empty. m4_define(pcre_major, [8]) -m4_define(pcre_minor, [41]) +m4_define(pcre_minor, [42]) m4_define(pcre_prerelease, []) -m4_define(pcre_date, [2017-07-05]) +m4_define(pcre_date, [2018-03-20]) # NOTE: The CMakeLists.txt file searches for the above variables in the first # 50 lines of this file. Please update that if the variables above are moved. # Libtool shared library interface versions (current:revision:age) -m4_define(libpcre_version, [3:9:2]) -m4_define(libpcre16_version, [2:9:2]) -m4_define(libpcre32_version, [0:9:0]) -m4_define(libpcreposix_version, [0:5:0]) +m4_define(libpcre_version, [3:10:2]) +m4_define(libpcre16_version, [2:10:2]) +m4_define(libpcre32_version, [0:10:0]) +m4_define(libpcreposix_version, [0:6:0]) m4_define(libpcrecpp_version, [0:1:0]) AC_PREREQ(2.57) @@ -155,6 +155,18 @@ AC_ARG_ENABLE(jit, [enable Just-In-Time compiling support]), , enable_jit=no) +# This code enables JIT if the hardware supports it. + +if test "$enable_jit" = "auto"; then + AC_LANG(C) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #define SLJIT_CONFIG_AUTO 1 + #include "sljit/sljitConfigInternal.h" + #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) + #error unsupported + #endif]])], enable_jit=yes, enable_jit=no) +fi + # Handle --disable-pcregrep-jit (enabled by default) AC_ARG_ENABLE(pcregrep-jit, AS_HELP_STRING([--disable-pcregrep-jit], @@ -469,7 +481,7 @@ pcre_have_type_traits="0" pcre_have_bits_type_traits="0" if test "x$enable_cpp" = "xyes" -a -z "$CXX"; then - AC_MSG_ERROR([You need a C++ compiler for C++ support.]) + AC_MSG_ERROR([Invalid C++ compiler or C++ compiler flags]) fi if test "x$enable_cpp" = "xyes" -a -n "$CXX" diff --git a/pcre/doc/html/NON-AUTOTOOLS-BUILD.txt b/pcre/doc/html/NON-AUTOTOOLS-BUILD.txt index 3910059106bd3a8c11ca75c2c02f25627de7b1ea..37f6164475b37ce190c62dce51d56e73fb11b499 100644 --- a/pcre/doc/html/NON-AUTOTOOLS-BUILD.txt +++ b/pcre/doc/html/NON-AUTOTOOLS-BUILD.txt @@ -760,13 +760,14 @@ The character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and applications can be supported through UNIX System Services, and in such an environment PCRE can be built in the same way as in other systems. However, in native z/OS (without UNIX System Services) and in z/VM, special ports are -required. For details, please see this web site: +required. PCRE1 version 8.39 is available in file 882 on this site: - http://www.zaconsultants.net + http://www.cbttape.org -You may download PCRE from WWW.CBTTAPE.ORG, file 882.  Everything, source and -executable, is in EBCDIC and native z/OS file formats and this is the -recommended download site. +Everything, source and executable, is in EBCDIC and native z/OS file formats. +However, this software is not maintained and will not be upgraded. If you are +new to PCRE you should be looking at PCRE2 (version 10.30 or later). -========================== -Last Updated: 25 June 2015 +=============================== +Last Updated: 13 September 2017 +=============================== diff --git a/pcre/pcre.h.in b/pcre/pcre.h.in index 667a45ed5757573474b49ee9cf6d489dc1016416..d4d78926984840491164649104dd41be705c9714 100644 --- a/pcre/pcre.h.in +++ b/pcre/pcre.h.in @@ -321,11 +321,11 @@ these bits, just add new ones on the end, in order to remain compatible. */ /* Types */ -struct real_pcre; /* declaration; the definition is private */ -typedef struct real_pcre pcre; +struct real_pcre8_or_16; /* declaration; the definition is private */ +typedef struct real_pcre8_or_16 pcre; -struct real_pcre16; /* declaration; the definition is private */ -typedef struct real_pcre16 pcre16; +struct real_pcre8_or_16; /* declaration; the definition is private */ +typedef struct real_pcre8_or_16 pcre16; struct real_pcre32; /* declaration; the definition is private */ typedef struct real_pcre32 pcre32; diff --git a/pcre/pcre_compile.c b/pcre/pcre_compile.c index 1a916693e699ce505af483baad946dcf2ef8e496..9b9da46f0d090744b8653ba9dc1bc6c38c96ae97 100644 --- a/pcre/pcre_compile.c +++ b/pcre/pcre_compile.c @@ -8063,7 +8063,7 @@ for (;; ptr++) single group (i.e. not to a duplicated name. */ HANDLE_REFERENCE: - if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE; + if (firstcharflags == REQ_UNSET) zerofirstcharflags = firstcharflags = REQ_NONE; previous = code; item_hwm_offset = cd->hwm - cd->start_workspace; *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF; diff --git a/pcre/pcre_dfa_exec.c b/pcre/pcre_dfa_exec.c index bc09ced3a7c5b1a1a48cba2a634926ca66e9e49f..f333381d0883b9e79152ed0a43fc1d1ba340064c 100644 --- a/pcre/pcre_dfa_exec.c +++ b/pcre/pcre_dfa_exec.c @@ -2287,12 +2287,14 @@ for (;;) case OP_NOTI: if (clen > 0) { - unsigned int otherd; + pcre_uint32 otherd; #ifdef SUPPORT_UTF if (utf && d >= 128) { #ifdef SUPPORT_UCP otherd = UCD_OTHERCASE(d); +#else + otherd = d; #endif /* SUPPORT_UCP */ } else diff --git a/pcre/pcre_exec.c b/pcre/pcre_exec.c index fa84d924a4c6463e06b7ec4f30d475066d5d9399..93256d32455020a0e7758c67f27dff4f91a78962 100644 --- a/pcre/pcre_exec.c +++ b/pcre/pcre_exec.c @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2014 University of Cambridge + Copyright (c) 1997-2018 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -2313,7 +2313,7 @@ for (;;) case OP_ANY: if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); if (md->partial != 0 && - eptr + 1 >= md->end_subject && + eptr == md->end_subject - 1 && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && UCHAR21TEST(eptr) == NLBLOCK->nl[0]) @@ -3061,7 +3061,7 @@ for (;;) { RMATCH(eptr, ecode, offset_top, md, eptrb, RM18); if (rrc != MATCH_NOMATCH) RRETURN(rrc); - if (eptr-- == pp) break; /* Stop if tried at original pos */ + if (eptr-- <= pp) break; /* Stop if tried at original pos */ BACKCHAR(eptr); } } @@ -3218,7 +3218,7 @@ for (;;) { RMATCH(eptr, ecode, offset_top, md, eptrb, RM21); if (rrc != MATCH_NOMATCH) RRETURN(rrc); - if (eptr-- == pp) break; /* Stop if tried at original pos */ + if (eptr-- <= pp) break; /* Stop if tried at original pos */ #ifdef SUPPORT_UTF if (utf) BACKCHAR(eptr); #endif diff --git a/pcre/pcre_jit_compile.c b/pcre/pcre_jit_compile.c index 249edbe8e7f4f0e5820693bd7fa9e172b264bff6..2bad74b02317c99f6939f5dc2bb17a90d06d5ddc 100644 --- a/pcre/pcre_jit_compile.c +++ b/pcre/pcre_jit_compile.c @@ -164,7 +164,6 @@ typedef struct jit_arguments { const pcre_uchar *begin; const pcre_uchar *end; int *offsets; - pcre_uchar *uchar_ptr; pcre_uchar *mark_ptr; void *callout_data; /* Everything else after. */ @@ -214,7 +213,7 @@ enum control_types { type_then_trap = 1 }; -typedef int (SLJIT_CALL *jit_function)(jit_arguments *args); +typedef int (SLJIT_FUNC *jit_function)(jit_arguments *args); /* The following structure is the key data type for the recursive code generator. It is allocated by compile_matchingpath, and contains @@ -489,9 +488,24 @@ typedef struct compare_context { /* Used for accessing the elements of the stack. */ #define STACK(i) ((i) * (int)sizeof(sljit_sw)) +#ifdef SLJIT_PREF_SHIFT_REG +#if SLJIT_PREF_SHIFT_REG == SLJIT_R2 +/* Nothing. */ +#elif SLJIT_PREF_SHIFT_REG == SLJIT_R3 +#define SHIFT_REG_IS_R3 +#else +#error "Unsupported shift register" +#endif +#endif + #define TMP1 SLJIT_R0 +#ifdef SHIFT_REG_IS_R3 +#define TMP2 SLJIT_R3 +#define TMP3 SLJIT_R2 +#else #define TMP2 SLJIT_R2 #define TMP3 SLJIT_R3 +#endif #define STR_PTR SLJIT_S0 #define STR_END SLJIT_S1 #define STACK_TOP SLJIT_R1 @@ -520,13 +534,10 @@ the start pointers when the end of the capturing group has not yet reached. */ #if defined COMPILE_PCRE8 #define MOV_UCHAR SLJIT_MOV_U8 -#define MOVU_UCHAR SLJIT_MOVU_U8 #elif defined COMPILE_PCRE16 #define MOV_UCHAR SLJIT_MOV_U16 -#define MOVU_UCHAR SLJIT_MOVU_U16 #elif defined COMPILE_PCRE32 #define MOV_UCHAR SLJIT_MOV_U32 -#define MOVU_UCHAR SLJIT_MOVU_U32 #else #error Unsupported compiling mode #endif @@ -2383,12 +2394,25 @@ if (length < 8) } else { - GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START); - OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1); - loop = LABEL(); - OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw), SLJIT_R0, 0); - OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, loop); + if (sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_STORE | SLJIT_MEM_PRE, SLJIT_R0, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw)) == SLJIT_SUCCESS) + { + GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1); + loop = LABEL(); + sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_STORE | SLJIT_MEM_PRE, SLJIT_R0, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw)); + OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, loop); + } + else + { + GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START + sizeof(sljit_sw)); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1); + loop = LABEL(); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R0, 0); + OP2(SLJIT_ADD, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, sizeof(sljit_sw)); + OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, loop); + } } } @@ -2421,12 +2445,25 @@ if (length < 8) } else { - GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + sizeof(sljit_sw)); - OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, length - 2); - loop = LABEL(); - OP1(SLJIT_MOVU, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0); - OP2(SLJIT_SUB | SLJIT_SET_Z, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, loop); + if (sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_STORE | SLJIT_MEM_PRE, TMP1, SLJIT_MEM1(TMP2), sizeof(sljit_sw)) == SLJIT_SUCCESS) + { + GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + sizeof(sljit_sw)); + OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, length - 2); + loop = LABEL(); + sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_STORE | SLJIT_MEM_PRE, TMP1, SLJIT_MEM1(TMP2), sizeof(sljit_sw)); + OP2(SLJIT_SUB | SLJIT_SET_Z, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, loop); + } + else + { + GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + 2 * sizeof(sljit_sw)); + OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, length - 2); + loop = LABEL(); + OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, TMP1, 0); + OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, sizeof(sljit_sw)); + OP2(SLJIT_SUB | SLJIT_SET_Z, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, loop); + } } OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0); @@ -2436,10 +2473,10 @@ if (common->control_head_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack)); OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); -OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, base)); +OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, end)); } -static sljit_sw SLJIT_CALL do_search_mark(sljit_sw *current, const pcre_uchar *skip_arg) +static sljit_sw SLJIT_FUNC do_search_mark(sljit_sw *current, const pcre_uchar *skip_arg) { while (current != NULL) { @@ -2460,7 +2497,7 @@ while (current != NULL) SLJIT_ASSERT(current[0] == 0 || current < (sljit_sw*)current[0]); current = (sljit_sw*)current[0]; } -return -1; +return 0; } static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket) @@ -2468,6 +2505,7 @@ static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket) DEFINE_COMPILER; struct sljit_label *loop; struct sljit_jump *early_quit; +BOOL has_pre; /* At this point we can freely use all registers. */ OP1(SLJIT_MOV, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)); @@ -2481,17 +2519,30 @@ if (common->mark_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R2, 0); OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offsets), SLJIT_IMM, sizeof(int)); OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, begin)); -GET_LOCAL_BASE(SLJIT_S0, 0, OVECTOR_START); + +has_pre = sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, SLJIT_S1, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw)) == SLJIT_SUCCESS; +GET_LOCAL_BASE(SLJIT_S0, 0, OVECTOR_START - (has_pre ? sizeof(sljit_sw) : 0)); + /* Unlikely, but possible */ early_quit = CMP(SLJIT_EQUAL, SLJIT_R1, 0, SLJIT_IMM, 0); loop = LABEL(); -OP2(SLJIT_SUB, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 0, SLJIT_R0, 0); -OP2(SLJIT_ADD, SLJIT_S0, 0, SLJIT_S0, 0, SLJIT_IMM, sizeof(sljit_sw)); + +if (has_pre) + sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_PRE, SLJIT_S1, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw)); +else + { + OP1(SLJIT_MOV, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 0); + OP2(SLJIT_ADD, SLJIT_S0, 0, SLJIT_S0, 0, SLJIT_IMM, sizeof(sljit_sw)); + } + +OP2(SLJIT_ADD, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, sizeof(int)); +OP2(SLJIT_SUB, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_R0, 0); /* Copy the integer value to the output buffer */ #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOVU_S32, SLJIT_MEM1(SLJIT_R2), sizeof(int), SLJIT_S1, 0); + +OP1(SLJIT_MOV_S32, SLJIT_MEM1(SLJIT_R2), 0, SLJIT_S1, 0); OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); JUMPTO(SLJIT_NOT_ZERO, loop); JUMPHERE(early_quit); @@ -2499,14 +2550,29 @@ JUMPHERE(early_quit); /* Calculate the return value, which is the maximum ovector value. */ if (topbracket > 1) { - GET_LOCAL_BASE(SLJIT_R0, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_sw)); - OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, topbracket + 1); + if (sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, SLJIT_R2, SLJIT_MEM1(SLJIT_R0), -(2 * (sljit_sw)sizeof(sljit_sw))) == SLJIT_SUCCESS) + { + GET_LOCAL_BASE(SLJIT_R0, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_sw)); + OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, topbracket + 1); - /* OVECTOR(0) is never equal to SLJIT_S2. */ - loop = LABEL(); - OP1(SLJIT_MOVU, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), -(2 * (sljit_sw)sizeof(sljit_sw))); - OP2(SLJIT_SUB, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); - CMPTO(SLJIT_EQUAL, SLJIT_R2, 0, SLJIT_S2, 0, loop); + /* OVECTOR(0) is never equal to SLJIT_S2. */ + loop = LABEL(); + sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_PRE, SLJIT_R2, SLJIT_MEM1(SLJIT_R0), -(2 * (sljit_sw)sizeof(sljit_sw))); + OP2(SLJIT_SUB, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); + CMPTO(SLJIT_EQUAL, SLJIT_R2, 0, SLJIT_S2, 0, loop); + } + else + { + GET_LOCAL_BASE(SLJIT_R0, 0, OVECTOR_START + (topbracket - 1) * 2 * sizeof(sljit_sw)); + OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, topbracket + 1); + + /* OVECTOR(0) is never equal to SLJIT_S2. */ + loop = LABEL(); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), 0); + OP2(SLJIT_SUB, SLJIT_R0, 0, SLJIT_R0, 0, SLJIT_IMM, 2 * (sljit_sw)sizeof(sljit_sw)); + OP2(SLJIT_SUB, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); + CMPTO(SLJIT_EQUAL, SLJIT_R2, 0, SLJIT_S2, 0, loop); + } OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_R1, 0); } else @@ -5167,93 +5233,190 @@ OP_FLAGS(SLJIT_OR | SLJIT_SET_Z, TMP2, 0, SLJIT_EQUAL); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); } -#define CHAR1 STR_END -#define CHAR2 STACK_TOP - static void do_casefulcmp(compiler_common *common) { DEFINE_COMPILER; struct sljit_jump *jump; struct sljit_label *label; +int char1_reg; +int char2_reg; -sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); +if (sljit_get_register_index(TMP3) < 0) + { + char1_reg = STR_END; + char2_reg = STACK_TOP; + } +else + { + char1_reg = TMP3; + char2_reg = RETURN_ADDR; + } + +sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0); OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP3, 0, CHAR1, 0); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, CHAR2, 0); -OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -label = LABEL(); -OP1(MOVU_UCHAR, CHAR1, 0, SLJIT_MEM1(TMP1), IN_UCHARS(1)); -OP1(MOVU_UCHAR, CHAR2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -jump = CMP(SLJIT_NOT_EQUAL, CHAR1, 0, CHAR2, 0); -OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); -JUMPTO(SLJIT_NOT_ZERO, label); +if (char1_reg == STR_END) + { + OP1(SLJIT_MOV, TMP3, 0, char1_reg, 0); + OP1(SLJIT_MOV, RETURN_ADDR, 0, char2_reg, 0); + } -JUMPHERE(jump); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -OP1(SLJIT_MOV, CHAR1, 0, TMP3, 0); -OP1(SLJIT_MOV, CHAR2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); -sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -} +if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS) + { + label = LABEL(); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + jump = CMP(SLJIT_NOT_EQUAL, char1_reg, 0, char2_reg, 0); + OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPTO(SLJIT_NOT_ZERO, label); + + JUMPHERE(jump); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + } +else if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + + label = LABEL(); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + jump = CMP(SLJIT_NOT_EQUAL, char1_reg, 0, char2_reg, 0); + OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPTO(SLJIT_NOT_ZERO, label); -#define LCC_TABLE STACK_LIMIT + JUMPHERE(jump); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } +else + { + label = LABEL(); + OP1(MOV_UCHAR, char1_reg, 0, SLJIT_MEM1(TMP1), 0); + OP1(MOV_UCHAR, char2_reg, 0, SLJIT_MEM1(STR_PTR), 0); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + jump = CMP(SLJIT_NOT_EQUAL, char1_reg, 0, char2_reg, 0); + OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPTO(SLJIT_NOT_ZERO, label); + + JUMPHERE(jump); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + } + +if (char1_reg == STR_END) + { + OP1(SLJIT_MOV, char1_reg, 0, TMP3, 0); + OP1(SLJIT_MOV, char2_reg, 0, RETURN_ADDR, 0); + } + +sljit_emit_fast_return(compiler, TMP1, 0); +} static void do_caselesscmp(compiler_common *common) { DEFINE_COMPILER; struct sljit_jump *jump; struct sljit_label *label; +int char1_reg = STR_END; +int char2_reg; +int lcc_table; +int opt_type = 0; -sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); +if (sljit_get_register_index(TMP3) < 0) + { + char2_reg = STACK_TOP; + lcc_table = STACK_LIMIT; + } +else + { + char2_reg = RETURN_ADDR; + lcc_table = TMP3; + } + +if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS) + opt_type = 1; +else if (sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)) == SLJIT_SUCCESS) + opt_type = 2; + +sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0); OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP3, 0, LCC_TABLE, 0); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, CHAR1, 0); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, CHAR2, 0); -OP1(SLJIT_MOV, LCC_TABLE, 0, SLJIT_IMM, common->lcc); -OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, char1_reg, 0); + +if (char2_reg == STACK_TOP) + { + OP1(SLJIT_MOV, TMP3, 0, char2_reg, 0); + OP1(SLJIT_MOV, RETURN_ADDR, 0, lcc_table, 0); + } + +OP1(SLJIT_MOV, lcc_table, 0, SLJIT_IMM, common->lcc); + +if (opt_type == 1) + { + label = LABEL(); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_POST, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + } +else if (opt_type == 2) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + + label = LABEL(); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char1_reg, SLJIT_MEM1(TMP1), IN_UCHARS(1)); + sljit_emit_mem(compiler, MOV_UCHAR | SLJIT_MEM_PRE, char2_reg, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + } +else + { + label = LABEL(); + OP1(MOV_UCHAR, char1_reg, 0, SLJIT_MEM1(TMP1), 0); + OP1(MOV_UCHAR, char2_reg, 0, SLJIT_MEM1(STR_PTR), 0); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1)); + } -label = LABEL(); -OP1(MOVU_UCHAR, CHAR1, 0, SLJIT_MEM1(TMP1), IN_UCHARS(1)); -OP1(MOVU_UCHAR, CHAR2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); #ifndef COMPILE_PCRE8 -jump = CMP(SLJIT_GREATER, CHAR1, 0, SLJIT_IMM, 255); +jump = CMP(SLJIT_GREATER, char1_reg, 0, SLJIT_IMM, 255); #endif -OP1(SLJIT_MOV_U8, CHAR1, 0, SLJIT_MEM2(LCC_TABLE, CHAR1), 0); +OP1(SLJIT_MOV_U8, char1_reg, 0, SLJIT_MEM2(lcc_table, char1_reg), 0); #ifndef COMPILE_PCRE8 JUMPHERE(jump); -jump = CMP(SLJIT_GREATER, CHAR2, 0, SLJIT_IMM, 255); +jump = CMP(SLJIT_GREATER, char2_reg, 0, SLJIT_IMM, 255); #endif -OP1(SLJIT_MOV_U8, CHAR2, 0, SLJIT_MEM2(LCC_TABLE, CHAR2), 0); +OP1(SLJIT_MOV_U8, char2_reg, 0, SLJIT_MEM2(lcc_table, char2_reg), 0); #ifndef COMPILE_PCRE8 JUMPHERE(jump); #endif -jump = CMP(SLJIT_NOT_EQUAL, CHAR1, 0, CHAR2, 0); + +if (opt_type == 0) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + +jump = CMP(SLJIT_NOT_EQUAL, char1_reg, 0, char2_reg, 0); OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); JUMPTO(SLJIT_NOT_ZERO, label); JUMPHERE(jump); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -OP1(SLJIT_MOV, LCC_TABLE, 0, TMP3, 0); -OP1(SLJIT_MOV, CHAR1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); -OP1(SLJIT_MOV, CHAR2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1); -sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -} +OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + +if (opt_type == 2) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -#undef LCC_TABLE -#undef CHAR1 -#undef CHAR2 +if (char2_reg == STACK_TOP) + { + OP1(SLJIT_MOV, char2_reg, 0, TMP3, 0); + OP1(SLJIT_MOV, lcc_table, 0, RETURN_ADDR, 0); + } + +OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1); +sljit_emit_fast_return(compiler, TMP1, 0); +} #if defined SUPPORT_UTF && defined SUPPORT_UCP -static const pcre_uchar * SLJIT_CALL do_utf_caselesscmp(pcre_uchar *src1, jit_arguments *args, pcre_uchar *end1) +static const pcre_uchar * SLJIT_FUNC do_utf_caselesscmp(pcre_uchar *src1, pcre_uchar *src2, pcre_uchar *end1, pcre_uchar *end2) { /* This function would be ineffective to do in JIT level. */ sljit_u32 c1, c2; -const pcre_uchar *src2 = args->uchar_ptr; -const pcre_uchar *end2 = args->end; const ucd_record *ur; const sljit_u32 *pp; @@ -6776,32 +6939,37 @@ else #if defined SUPPORT_UTF && defined SUPPORT_UCP if (common->utf && *cc == OP_REFI) { - SLJIT_ASSERT(TMP1 == SLJIT_R0 && STACK_TOP == SLJIT_R1 && TMP2 == SLJIT_R2); + SLJIT_ASSERT(TMP1 == SLJIT_R0 && STACK_TOP == SLJIT_R1); if (ref) - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1)); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1)); else - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw)); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw)); if (withchecks) - jump = CMP(SLJIT_EQUAL, TMP1, 0, TMP2, 0); + jump = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_R2, 0); - /* Needed to save important temporary registers. */ + /* No free saved registers so save data on stack. */ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); - OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, uchar_ptr), STR_PTR, 0); - sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp)); + OP1(SLJIT_MOV, SLJIT_R1, 0, STR_PTR, 0); + OP1(SLJIT_MOV, SLJIT_R3, 0, STR_END, 0); + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp)); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0); + if (common->mode == JIT_COMPILE) add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1)); else { - add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0)); - nopartial = CMP(SLJIT_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1); + OP2(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_LESS, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1); + + add_jump(compiler, backtracks, JUMP(SLJIT_LESS)); + + nopartial = JUMP(SLJIT_NOT_EQUAL); + OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0); check_partial(common, FALSE); add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); JUMPHERE(nopartial); } - OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0); } else #endif /* SUPPORT_UTF && SUPPORT_UCP */ @@ -7125,7 +7293,7 @@ add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IM return cc + 1 + LINK_SIZE; } -static int SLJIT_CALL do_callout(struct jit_arguments *arguments, PUBL(callout_block) *callout_block, pcre_uchar **jit_ovector) +static sljit_s32 SLJIT_FUNC do_callout(struct jit_arguments *arguments, PUBL(callout_block) *callout_block, pcre_uchar **jit_ovector) { const pcre_uchar *begin = arguments->begin; int *offset_vector = arguments->offsets; @@ -7207,18 +7375,17 @@ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); /* SLJIT_R0 = arguments */ OP1(SLJIT_MOV, SLJIT_R1, 0, STACK_TOP, 0); GET_LOCAL_BASE(SLJIT_R2, 0, OVECTOR_START); -sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_callout)); -OP1(SLJIT_MOV_S32, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0); +sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(S32) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW), SLJIT_IMM, SLJIT_FUNC_OFFSET(do_callout)); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); free_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw)); /* Check return value. */ -OP2(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_SIG_GREATER, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); -add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_SIG_GREATER)); +OP2(SLJIT_SUB32 | SLJIT_SET_Z | SLJIT_SET_SIG_GREATER, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); +add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_SIG_GREATER32)); if (common->forced_quit_label == NULL) - add_jump(compiler, &common->forced_quit, JUMP(SLJIT_NOT_EQUAL) /* SIG_LESS */); + add_jump(compiler, &common->forced_quit, JUMP(SLJIT_NOT_EQUAL32) /* SIG_LESS */); else - JUMPTO(SLJIT_NOT_EQUAL /* SIG_LESS */, common->forced_quit_label); + JUMPTO(SLJIT_NOT_EQUAL32 /* SIG_LESS */, common->forced_quit_label); return cc + 2 + 2 * LINK_SIZE; } @@ -10439,11 +10606,11 @@ if (opcode == OP_SKIP_ARG) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, (sljit_sw)(current->cc + 2)); - sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_mark)); + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW), SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_mark)); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0); - add_jump(compiler, &common->reset_match, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, -1)); + add_jump(compiler, &common->reset_match, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0)); return; } @@ -11031,7 +11198,7 @@ if (!compiler) common->compiler = compiler; /* Main pcre_jit_exec entry. */ -sljit_emit_enter(compiler, 0, 1, 5, 5, 0, 0, private_data_size); +sljit_emit_enter(compiler, 0, SLJIT_ARG1(SW), 5, 5, 0, 0, private_data_size); /* Register init. */ reset_ovector(common, (re->top_bracket + 1) * 2); @@ -11044,8 +11211,8 @@ OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)) OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack)); OP1(SLJIT_MOV_U32, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match)); -OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base)); -OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit)); +OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, end)); +OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, start)); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH, TMP1, 0); @@ -11251,20 +11418,22 @@ common->quit_label = quit_label; set_jumps(common->stackalloc, LABEL()); /* RETURN_ADDR is not a saved register. */ sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP2, 0); -OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack)); -OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, top), STACK_TOP, 0); -OP2(SLJIT_SUB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, limit), SLJIT_IMM, STACK_GROWTH_RATE); -sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize)); -jump = CMP(SLJIT_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); -OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack)); -OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, top)); -OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, limit)); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1); -sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0); +SLJIT_ASSERT(TMP1 == SLJIT_R0 && STACK_TOP == SLJIT_R1); + +OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, STACK_TOP, 0); +OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0); +OP2(SLJIT_SUB, SLJIT_R1, 0, STACK_LIMIT, 0, SLJIT_IMM, STACK_GROWTH_RATE); +OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, stack)); +OP1(SLJIT_MOV, STACK_LIMIT, 0, TMP2, 0); + +sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW), SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize)); +jump = CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); +OP1(SLJIT_MOV, TMP2, 0, STACK_LIMIT, 0); +OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_RETURN_REG, 0); +OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); +OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1); +sljit_emit_fast_return(compiler, TMP1, 0); /* Allocation failed. */ JUMPHERE(jump); @@ -11409,9 +11578,9 @@ union { sljit_u8 local_space[MACHINE_STACK_SIZE]; struct sljit_stack local_stack; -local_stack.max_limit = local_space; -local_stack.limit = local_space; -local_stack.base = local_space + MACHINE_STACK_SIZE; +local_stack.min_start = local_space; +local_stack.start = local_space; +local_stack.end = local_space + MACHINE_STACK_SIZE; local_stack.top = local_space + MACHINE_STACK_SIZE; arguments->stack = &local_stack; convert_executable_func.executable_func = executable_func; @@ -11529,7 +11698,7 @@ if ((options & PCRE_PARTIAL_HARD) != 0) else if ((options & PCRE_PARTIAL_SOFT) != 0) mode = JIT_PARTIAL_SOFT_COMPILE; -if (functions->executable_funcs[mode] == NULL) +if (functions == NULL || functions->executable_funcs[mode] == NULL) return PCRE_ERROR_JIT_BADOPTION; /* Sanity checks should be handled by pcre_exec. */ diff --git a/pcre/pcregrep.c b/pcre/pcregrep.c index 317f7454e136781d82a21518ed02bfb396bef810..a406be962d77088c4d41a1b0d57bd4e7ea2fe7a7 100644 --- a/pcre/pcregrep.c +++ b/pcre/pcregrep.c @@ -1387,8 +1387,8 @@ Returns: nothing */ static void -do_after_lines(int lastmatchnumber, char *lastmatchrestart, char *endptr, - char *printname) +do_after_lines(unsigned long int lastmatchnumber, char *lastmatchrestart, + char *endptr, char *printname) { if (after_context > 0 && lastmatchnumber > 0) { @@ -1398,7 +1398,7 @@ if (after_context > 0 && lastmatchnumber > 0) int ellength; char *pp = lastmatchrestart; if (printname != NULL) fprintf(stdout, "%s-", printname); - if (number) fprintf(stdout, "%d-", lastmatchnumber++); + if (number) fprintf(stdout, "%lu-", lastmatchnumber++); pp = end_of_line(pp, endptr, &ellength); FWRITE(lastmatchrestart, 1, pp - lastmatchrestart, stdout); lastmatchrestart = pp; @@ -1502,11 +1502,11 @@ static int pcregrep(void *handle, int frtype, char *filename, char *printname) { int rc = 1; -int linenumber = 1; -int lastmatchnumber = 0; -int count = 0; int filepos = 0; int offsets[OFFSET_SIZE]; +unsigned long int linenumber = 1; +unsigned long int lastmatchnumber = 0; +unsigned long int count = 0; char *lastmatchrestart = NULL; char *ptr = main_buffer; char *endptr; @@ -1609,7 +1609,7 @@ while (ptr < endptr) if (endlinelength == 0 && t == main_buffer + bufsize) { - fprintf(stderr, "pcregrep: line %d%s%s is too long for the internal buffer\n" + fprintf(stderr, "pcregrep: line %lu%s%s is too long for the internal buffer\n" "pcregrep: check the --buffer-size option\n", linenumber, (filename == NULL)? "" : " of file ", @@ -1747,7 +1747,7 @@ while (ptr < endptr) prevoffsets[1] = offsets[1]; if (printname != NULL) fprintf(stdout, "%s:", printname); - if (number) fprintf(stdout, "%d:", linenumber); + if (number) fprintf(stdout, "%lu:", linenumber); /* Handle --line-offsets */ @@ -1862,7 +1862,7 @@ while (ptr < endptr) { char *pp = lastmatchrestart; if (printname != NULL) fprintf(stdout, "%s-", printname); - if (number) fprintf(stdout, "%d-", lastmatchnumber++); + if (number) fprintf(stdout, "%lu-", lastmatchnumber++); pp = end_of_line(pp, endptr, &ellength); FWRITE(lastmatchrestart, 1, pp - lastmatchrestart, stdout); lastmatchrestart = pp; @@ -1902,7 +1902,7 @@ while (ptr < endptr) int ellength; char *pp = p; if (printname != NULL) fprintf(stdout, "%s-", printname); - if (number) fprintf(stdout, "%d-", linenumber - linecount--); + if (number) fprintf(stdout, "%lu-", linenumber - linecount--); pp = end_of_line(pp, endptr, &ellength); FWRITE(p, 1, pp - p, stdout); p = pp; @@ -1916,7 +1916,7 @@ while (ptr < endptr) endhyphenpending = TRUE; if (printname != NULL) fprintf(stdout, "%s:", printname); - if (number) fprintf(stdout, "%d:", linenumber); + if (number) fprintf(stdout, "%lu:", linenumber); /* In multiline mode, we want to print to the end of the line in which the end of the matched string is found, so we adjust linelength and the @@ -2112,7 +2112,7 @@ if (count_only && !quiet) { if (printname != NULL && filenames != FN_NONE) fprintf(stdout, "%s:", printname); - fprintf(stdout, "%d\n", count); + fprintf(stdout, "%lu\n", count); } } @@ -2234,7 +2234,7 @@ if (isdirectory(pathname)) if (dee_action == dee_RECURSE) { - char buffer[1024]; + char buffer[2048]; char *nextfile; directory_type *dir = opendirectory(pathname); @@ -2249,7 +2249,14 @@ if (isdirectory(pathname)) while ((nextfile = readdirectory(dir)) != NULL) { int frc; - sprintf(buffer, "%.512s%c%.128s", pathname, FILESEP, nextfile); + int fnlength = strlen(pathname) + strlen(nextfile) + 2; + if (fnlength > 2048) + { + fprintf(stderr, "pcre2grep: recursive filename is too long\n"); + rc = 2; + break; + } + sprintf(buffer, "%s%c%s", pathname, FILESEP, nextfile); frc = grep_or_recurse(buffer, dir_recurse, FALSE); if (frc > 1) rc = frc; else if (frc == 0 && rc == 1) rc = 0; @@ -2520,7 +2527,14 @@ if ((popts & PO_FIXED_STRINGS) != 0) } } -sprintf(buffer, "%s%.*s%s", prefix[popts], patlen, ps, suffix[popts]); +if (snprintf(buffer, PATBUFSIZE, "%s%.*s%s", prefix[popts], patlen, ps, + suffix[popts]) > PATBUFSIZE) + { + fprintf(stderr, "pcregrep: Buffer overflow while compiling \"%s\"\n", + ps); + return FALSE; + } + p->compiled = pcre_compile(buffer, options, &error, &errptr, pcretables); if (p->compiled != NULL) return TRUE; @@ -2756,8 +2770,15 @@ for (i = 1; i < argc; i++) int arglen = (argequals == NULL || equals == NULL)? (int)strlen(arg) : (int)(argequals - arg); - sprintf(buff1, "%.*s", baselen, op->long_name); - sprintf(buff2, "%s%.*s", buff1, fulllen - baselen - 2, opbra + 1); + if (snprintf(buff1, sizeof(buff1), "%.*s", baselen, op->long_name) > + (int)sizeof(buff1) || + snprintf(buff2, sizeof(buff2), "%s%.*s", buff1, + fulllen - baselen - 2, opbra + 1) > (int)sizeof(buff2)) + { + fprintf(stderr, "pcregrep: Buffer overflow when parsing %s option\n", + op->long_name); + pcregrep_exit(2); + } if (strncmp(arg, buff1, arglen) == 0 || strncmp(arg, buff2, arglen) == 0) diff --git a/pcre/pcreposix.c b/pcre/pcreposix.c index 7b404a711001a0f69060da86ca5915385d76023c..a76d6bfca45036b93e41a93977a00b4a0c5eacc1 100644 --- a/pcre/pcreposix.c +++ b/pcre/pcreposix.c @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2017 University of Cambridge + Copyright (c) 1997-2018 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -389,8 +389,8 @@ if (rc >= 0) { for (i = 0; i < (size_t)rc; i++) { - pmatch[i].rm_so = ovector[i*2] + so; - pmatch[i].rm_eo = ovector[i*2+1] + so; + pmatch[i].rm_so = (ovector[i*2] < 0)? -1 : ovector[i*2] + so; + pmatch[i].rm_eo = (ovector[i*2+1] < 0)? -1: ovector[i*2+1] + so; } if (allocated_ovector) free(ovector); for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1; diff --git a/pcre/testdata/testinput2 b/pcre/testdata/testinput2 index 08c6f39a565b9974d298a376e068334f4000789d..8ba4dc4ddaba708d280a35016f87ffdbbcda10a6 100644 --- a/pcre/testdata/testinput2 +++ b/pcre/testdata/testinput2 @@ -4249,4 +4249,12 @@ backtracking verbs. --/ /(?=.*[A-Z])/I +"(?<=(a))\1?b" + ab + aaab + +"(?=(a))\1?b" + ab + aaab + /-- End of testinput2 --/ diff --git a/pcre/testdata/testinput5 b/pcre/testdata/testinput5 index 28561a93572f9e0a74d87f1ce911c1195f3ba3c4..c94008c3f2981597a1903a3f40adc9404ebd936e 100644 --- a/pcre/testdata/testinput5 +++ b/pcre/testdata/testinput5 @@ -798,4 +798,10 @@ /(?<=\K\x{17f})/8G+ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f} +/\C[^\v]+\x80/8 + [Aá¿»BÅ€C] + +/\C[^\d]+\x80/8 + [Aá¿»BÅ€C] + /-- End of testinput5 --/ diff --git a/pcre/testdata/testoutput2 b/pcre/testdata/testoutput2 index 811bbefc84c091deb073a40709cd0f25b7619215..61ed8d9d4e404196c67a5613ab54c0b50bd0f89e 100644 --- a/pcre/testdata/testoutput2 +++ b/pcre/testdata/testoutput2 @@ -14705,4 +14705,20 @@ No options No first char No need char +"(?<=(a))\1?b" + ab + 0: b + 1: a + aaab + 0: ab + 1: a + +"(?=(a))\1?b" + ab + 0: ab + 1: a + aaab + 0: ab + 1: a + /-- End of testinput2 --/ diff --git a/pcre/testdata/testoutput5 b/pcre/testdata/testoutput5 index bab989ca7e5b2887cb1fa566d632e7c6e12fa829..090e1e1c85f0d46fface9a8193b9bdac8bf971a1 100644 --- a/pcre/testdata/testoutput5 +++ b/pcre/testdata/testoutput5 @@ -1942,4 +1942,12 @@ Need char = 'z' 0: \x{17f} 0+ +/\C[^\v]+\x80/8 + [Aá¿»BÅ€C] +No match + +/\C[^\d]+\x80/8 + [Aá¿»BÅ€C] +No match + /-- End of testinput5 --/ diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c index e62be946c4a9571873aad0a57b93c0d6928fed5d..c03ea12be74c06def8d8d06e2b45035bb23114a3 100644 --- a/plugin/auth_pam/mapper/pam_user_map.c +++ b/plugin/auth_pam/mapper/pam_user_map.c @@ -22,14 +22,24 @@ top: accounting @group_ro: readonly ========================================================= +If something doesn't work as expected you can get verbose +comments with the 'debug' option like this +========================================================= +auth required pam_user_map.so debug +========================================================= +These comments are written to the syslog as 'authpriv.debug' +and usually end up in /var/log/secure file. */ #include #include +#include +#include #include #include #include +#include #include #define FILENAME "/etc/security/user_map.conf" @@ -90,9 +100,42 @@ static int user_in_group(const gid_t *user_groups, int ng,const char *group) } +static void print_groups(pam_handle_t *pamh, const gid_t *user_groups, int ng) +{ + char buf[256]; + char *c_buf= buf, *buf_end= buf+sizeof(buf)-2; + struct group *gr; + int cg; + + for (cg=0; cg < ng; cg++) + { + char *c; + if (c_buf == buf_end) + break; + *(c_buf++)= ','; + if (!(gr= getgrgid(user_groups[cg])) || + !(c= gr->gr_name)) + continue; + while (*c) + { + if (c_buf == buf_end) + break; + *(c_buf++)= *(c++); + } + } + c_buf[0]= c_buf[1]= 0; + pam_syslog(pamh, LOG_DEBUG, "User belongs to %d %s [%s].\n", + ng, (ng == 1) ? "group" : "groups", buf+1); +} + + +static const char debug_keyword[]= "debug"; +#define SYSLOG_DEBUG if (mode_debug) pam_syslog + int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { + int mode_debug= 0; int pam_err, line= 0; const char *username; char buf[256]; @@ -101,6 +144,14 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, gid_t *groups= group_buffer; int n_groups= -1; + for (; argc > 0; argc--) + { + if (strcasecmp(argv[argc-1], debug_keyword) == 0) + mode_debug= 1; + } + + SYSLOG_DEBUG(pamh, LOG_DEBUG, "Opening file '%s'.\n", FILENAME); + f= fopen(FILENAME, "r"); if (f == NULL) { @@ -110,12 +161,18 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, pam_err = pam_get_item(pamh, PAM_USER, (const void**)&username); if (pam_err != PAM_SUCCESS) + { + pam_syslog(pamh, LOG_ERR, "Cannot get username.\n"); goto ret; + } + + SYSLOG_DEBUG(pamh, LOG_DEBUG, "Incoming username '%s'.\n", username); while (fgets(buf, sizeof(buf), f) != NULL) { char *s= buf, *from, *to, *end_from, *end_to; int check_group; + int cmp_result; line++; @@ -124,7 +181,11 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, if ((check_group= *s == '@')) { if (n_groups < 0) + { n_groups= populate_user_groups(username, &groups); + if (mode_debug) + print_groups(pamh, groups, n_groups); + } s++; } from= s; @@ -139,14 +200,30 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, if (end_to == to) goto syntax_error; *end_from= *end_to= 0; - if (check_group ? - user_in_group(groups, n_groups, from) : - (strcmp(username, from) == 0)) + + if (check_group) + { + cmp_result= user_in_group(groups, n_groups, from); + SYSLOG_DEBUG(pamh, LOG_DEBUG, "Check if user is in group '%s': %s\n", + from, cmp_result ? "YES":"NO"); + } + else + { + cmp_result= (strcmp(username, from) == 0); + SYSLOG_DEBUG(pamh, LOG_DEBUG, "Check if username '%s': %s\n", + from, cmp_result ? "YES":"NO"); + } + if (cmp_result) { pam_err= pam_set_item(pamh, PAM_USER, to); + SYSLOG_DEBUG(pamh, LOG_DEBUG, + (pam_err == PAM_SUCCESS) ? "User mapped as '%s'\n" : + "Couldn't map as '%s'\n", to); goto ret; } } + + SYSLOG_DEBUG(pamh, LOG_DEBUG, "User not found in the list.\n"); pam_err= PAM_AUTH_ERR; goto ret; @@ -162,6 +239,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, return pam_err; } + int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { diff --git a/plugin/disks/CMakeLists.txt b/plugin/disks/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..446c64d0fdddf56a5c6cb6ea917f36a7e3bb4fa3 --- /dev/null +++ b/plugin/disks/CMakeLists.txt @@ -0,0 +1,5 @@ +IF("${CMAKE_SYSTEM}" MATCHES "Linux") + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql) + MYSQL_ADD_PLUGIN(DISKS information_schema_disks.cc MODULE_ONLY RECOMPILE_FOR_EMBEDDED) +ENDIF() + diff --git a/plugin/disks/README.txt b/plugin/disks/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..b49db3c03b53571b697e34dd06cf7544dd951031 --- /dev/null +++ b/plugin/disks/README.txt @@ -0,0 +1,86 @@ +Information Schema Disks +------------------------ +This is a proof-of-concept information schema plugin that allows the +disk space situation to be monitored. When installed, it can be used +as follows: + + > select * from information_schema.disks; + +-----------+-----------------------+-----------+----------+-----------+ + | Disk | Path | Total | Used | Available | + +-----------+-----------------------+-----------+----------+-----------+ + | /dev/sda3 | / | 47929956 | 30666304 | 14805864 | + | /dev/sda1 | /boot/efi | 191551 | 3461 | 188090 | + | /dev/sda4 | /home | 174679768 | 80335392 | 85448120 | + | /dev/sdb1 | /mnt/hdd | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/Music | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/Videos | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/hdd | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/Pictures | 961301832 | 83764 | 912363644 | + | /dev/sda3 | /var/lib/docker/aufs | 47929956 | 30666304 | 14805864 | + +-----------+-----------------------+-----------+----------+-----------+ + 9 rows in set (0.00 sec) + +- 'Disk' is the name of the disk itself. +- 'Path' is the mount point of the disk. +- 'Total' is the total space in KiB. +- 'Used' is the used amount of space in KiB, and +- 'Available' is the amount of space in KiB available to non-root users. + +Note that as the amount of space available to root may be more that what +is available to non-root users, 'available' + 'used' may be less than 'total'. + +All paths to which a particular disk has been mounted are reported. The +rationale is that someone might want to take different action e.g. depending +on which disk is relevant for a particular path. This leads to the same disk +being reported multiple times. An alternative to this would be to have two +tables; disks and mounts. + + > select * from information_schema.disks; + +-----------+-----------+----------+-----------+ + | Disk | Total | Used | Available | + +-----------+-----------+----------+-----------+ + | /dev/sda3 | 47929956 | 30666304 | 14805864 | + | /dev/sda1 | 191551 | 3461 | 188090 | + | /dev/sda4 | 174679768 | 80335392 | 85448120 | + | /dev/sdb1 | 961301832 | 83764 | 912363644 | + +-----------+-----------+----------+-----------+ + + > select * from information_schema.mounts; + +-----------------------+-----------+ + | Path | Disk | + +-----------------------+-----------+ + | / | /dev/sda3 | + | /boot/efi | /dev/sda1 | + | /home | /dev/sda4 | + | /mnt/hdd | /dev/sdb1 | + | /home/wikman/Music | /dev/sdb1 | + ... + + +Installation +------------ + +- Use "install plugin" or "install soname" command: + + MariaDB [(none)]> install plugin disks soname 'disks.so'; + + or + + MariaDB [(none)]> install soname 'disks.so'; + +Usage +----- +The plugin appears as the table 'disks' in 'information_schema'. + + MariaDB [(none)]> select * from information_schema.disks; + +-----------+-----------------------+-----------+----------+-----------+ + | Disk | Path | Total | Used | Available | + +-----------+-----------------------+-----------+----------+-----------+ + | /dev/sda3 | / | 47929956 | 30666308 | 14805860 | + | /dev/sda1 | /boot/efi | 191551 | 3461 | 188090 | + | /dev/sda4 | /home | 174679768 | 80348148 | 85435364 | + | /dev/sdb1 | /mnt/hdd | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/Music | 961301832 | 83764 | 912363644 | + | /dev/sdb1 | /home/wikman/Videos | 961301832 | 83764 | 912363644 | + ... + diff --git a/plugin/disks/information_schema_disks.cc b/plugin/disks/information_schema_disks.cc new file mode 100644 index 0000000000000000000000000000000000000000..122b3d3f17f3bc5b19fc8435f30a0b25a7c0c8f9 --- /dev/null +++ b/plugin/disks/information_schema_disks.cc @@ -0,0 +1,155 @@ +/* + Copyright (c) 2017, MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + +#include +#include +#include +#include +#include + +bool schema_table_store_record(THD *thd, TABLE *table); + +namespace +{ + +struct st_mysql_information_schema disks_table_info = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + +ST_FIELD_INFO disks_table_fields[]= +{ + { "Disk", PATH_MAX, MYSQL_TYPE_STRING, 0, 0 ,0, 0 }, + { "Path", PATH_MAX, MYSQL_TYPE_STRING, 0, 0 ,0, 0 }, + { "Total", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Total amount available + { "Used", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Amount of space used + { "Available", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Amount available to users other than root. + { 0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0 } +}; + +int disks_table_add_row(THD* pThd, + TABLE* pTable, + const char* zDisk, + const char* zPath, + const struct statvfs& info) +{ + // From: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html + // + // f_frsize Fundamental file system block size. + // f_blocks Total number of blocks on file system in units of f_frsize. + // f_bfree Total number of free blocks. + // f_bavail Number of free blocks available to non-privileged process. + + size_t total = (info.f_frsize * info.f_blocks) / 1024; + size_t used = (info.f_frsize * (info.f_blocks - info.f_bfree)) / 1024; + size_t avail = (info.f_frsize * info.f_bavail) / 1024; + + pTable->field[0]->store(zDisk, strlen(zDisk), system_charset_info); + pTable->field[1]->store(zPath, strlen(zPath), system_charset_info); + pTable->field[2]->store(total); + pTable->field[3]->store(used); + pTable->field[4]->store(avail); + + // 0 means success. + return (schema_table_store_record(pThd, pTable) != 0) ? 1 : 0; +} + +int disks_table_add_row(THD* pThd, TABLE* pTable, const char* zDisk, const char* zPath) +{ + int rv = 0; + + struct statvfs info; + + if (statvfs(zPath, &info) == 0) // We ignore failures. + { + rv = disks_table_add_row(pThd, pTable, zDisk, zPath, info); + } + + return rv; +} + +int disks_fill_table(THD* pThd, TABLE_LIST* pTables, Item* pCond) +{ + int rv = 1; + TABLE* pTable = pTables->table; + + FILE* pFile = setmntent("/etc/mtab", "r"); + + if (pFile) + { + const size_t BUFFER_SIZE = 4096; // 4K should be sufficient. + + char* pBuffer = new (std::nothrow) char [BUFFER_SIZE]; + + if (pBuffer) + { + rv = 0; + + struct mntent ent; + struct mntent* pEnt; + + while ((rv == 0) && (pEnt = getmntent_r(pFile, &ent, pBuffer, BUFFER_SIZE))) + { + // We only report the ones that refer to physical disks. + if (pEnt->mnt_fsname[0] == '/') + { + rv = disks_table_add_row(pThd, pTable, pEnt->mnt_fsname, pEnt->mnt_dir); + } + } + + delete [] pBuffer; + } + else + { + rv = 1; + } + + endmntent(pFile); + } + + return rv; +} + +int disks_table_init(void *ptr) +{ + ST_SCHEMA_TABLE* pSchema_table = (ST_SCHEMA_TABLE*)ptr; + + pSchema_table->fields_info = disks_table_fields; + pSchema_table->fill_table = disks_fill_table; + return 0; +} + +} + +extern "C" +{ + +maria_declare_plugin(disks) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &disks_table_info, /* type-specific descriptor */ + "DISKS", /* table name */ + "Johan Wikman", /* author */ + "Disk space information", /* description */ + PLUGIN_LICENSE_GPL, /* license type */ + disks_table_init, /* init function */ + NULL, /* deinit function */ + 0x0100, /* version = 1.0 */ + NULL, /* no status variables */ + NULL, /* no system variables */ + "1.0", /* String version representation */ + MariaDB_PLUGIN_MATURITY_BETA /* Maturity (see include/mysql/plugin.h)*/ +} +mysql_declare_plugin_end; + +} diff --git a/plugin/disks/mysql-test/disks/disks.result b/plugin/disks/mysql-test/disks/disks.result new file mode 100644 index 0000000000000000000000000000000000000000..bd6befc5e11b9da94d6ea35ce74cfc4d28f87cb2 --- /dev/null +++ b/plugin/disks/mysql-test/disks/disks.result @@ -0,0 +1,12 @@ +show create table information_schema.disks; +Table Create Table +DISKS CREATE TEMPORARY TABLE `DISKS` ( + `Disk` varchar(4096) NOT NULL DEFAULT '', + `Path` varchar(4096) NOT NULL DEFAULT '', + `Total` int(32) NOT NULL DEFAULT '0', + `Used` int(32) NOT NULL DEFAULT '0', + `Available` int(32) NOT NULL DEFAULT '0' +) ENGINE=MEMORY DEFAULT CHARSET=utf8 +select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; +sum(Total) > sum(Available) sum(Total)>sum(Used) +1 1 diff --git a/plugin/disks/mysql-test/disks/disks.test b/plugin/disks/mysql-test/disks/disks.test new file mode 100644 index 0000000000000000000000000000000000000000..13a0762ae010fba53ff25fd31eff5e7fc5617424 --- /dev/null +++ b/plugin/disks/mysql-test/disks/disks.test @@ -0,0 +1,2 @@ +show create table information_schema.disks; +select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; diff --git a/plugin/disks/mysql-test/disks/suite.opt b/plugin/disks/mysql-test/disks/suite.opt new file mode 100644 index 0000000000000000000000000000000000000000..afbbe2b01630c90b76c25249582cc7b50f6dadb4 --- /dev/null +++ b/plugin/disks/mysql-test/disks/suite.opt @@ -0,0 +1 @@ +--plugin-load-add=$DISKS_SO diff --git a/plugin/disks/mysql-test/disks/suite.pm b/plugin/disks/mysql-test/disks/suite.pm new file mode 100644 index 0000000000000000000000000000000000000000..c64ef3b3133edea0faa64a36bc3e78ea7476fd4e --- /dev/null +++ b/plugin/disks/mysql-test/disks/suite.pm @@ -0,0 +1,10 @@ +package My::Suite::Disks; + +@ISA = qw(My::Suite); + +return "No Disks plugin" unless $ENV{DISKS_SO}; + +sub is_default { 1 } + +bless { }; + diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 0a266ab19fe83c20d1849f69acc003c50331223f..b5f6e996b424672c296ff777690237d7cb594d40 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -15,7 +15,7 @@ #define PLUGIN_VERSION 0x104 -#define PLUGIN_STR_VERSION "1.4.3" +#define PLUGIN_STR_VERSION "1.4.4" #define _my_thread_var loc_thread_var @@ -364,16 +364,17 @@ static MYSQL_SYSVAR_STR(excl_users, excl_users, PLUGIN_VAR_RQCMDARG, /* bits in the event filter. */ #define EVENT_CONNECT 1 #define EVENT_QUERY_ALL 2 -#define EVENT_QUERY 58 +#define EVENT_QUERY 122 #define EVENT_TABLE 4 #define EVENT_QUERY_DDL 8 #define EVENT_QUERY_DML 16 #define EVENT_QUERY_DCL 32 +#define EVENT_QUERY_DML_NO_SELECT 64 static const char *event_names[]= { "CONNECT", "QUERY", "TABLE", "QUERY_DDL", "QUERY_DML", "QUERY_DCL", - NULL + "QUERY_DML_NO_SELECT", NULL }; static TYPELIB events_typelib= { @@ -381,7 +382,7 @@ static TYPELIB events_typelib= }; static MYSQL_SYSVAR_SET(events, events, PLUGIN_VAR_RQCMDARG, "Specifies the set of events to monitor. Can be CONNECT, QUERY, TABLE," - " QUERY_DDL, QUERY_DML, QUERY_DCL.", + " QUERY_DDL, QUERY_DML, QUERY_DML_NO_SELECT, QUERY_DCL.", NULL, NULL, 0, &events_typelib); #define OUTPUT_SYSLOG 0 #define OUTPUT_FILE 1 @@ -855,6 +856,21 @@ struct sa_keyword dml_keywords[]= }; +struct sa_keyword dml_no_select_keywords[]= +{ + {2, "DO", 0, SQLCOM_DML}, + {4, "CALL", 0, SQLCOM_DML}, + {4, "LOAD", &data_word, SQLCOM_DML}, + {4, "LOAD", &xml_word, SQLCOM_DML}, + {6, "DELETE", 0, SQLCOM_DML}, + {6, "INSERT", 0, SQLCOM_DML}, + {6, "UPDATE", 0, SQLCOM_DML}, + {7, "HANDLER", 0, SQLCOM_DML}, + {7, "REPLACE", 0, SQLCOM_DML}, + {0, NULL, 0, SQLCOM_DML} +}; + + struct sa_keyword dcl_keywords[]= { {6, "CREATE", &user_word, SQLCOM_DCL}, @@ -1636,6 +1652,11 @@ static int log_statement_ex(const struct connection_info *cn, if (filter_query_type(query, dml_keywords)) goto do_log_query; } + if (events & EVENT_QUERY_DML_NO_SELECT) + { + if (filter_query_type(query, dml_no_select_keywords)) + goto do_log_query; + } if (events & EVENT_QUERY_DCL) { if (filter_query_type(query, dcl_keywords)) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 880458c1517ccd7dc93d74fa10fcc69ac630985c..b994c9f67b5ffed0ef4bf1cf1e3c0a39f0197b8c 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -366,6 +366,22 @@ ELSE() COMPONENT ${${file}_COMPONENT} ) ENDFOREACH() + SET (wsrep_sst_rsync_wan ${CMAKE_CURRENT_BINARY_DIR}/wsrep_sst_rsync_wan) + ADD_CUSTOM_COMMAND( + OUTPUT ${wsrep_sst_rsync_wan} + COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink + wsrep_sst_rsync + wsrep_sst_rsync_wan + ) + ADD_CUSTOM_TARGET(symlink_wsrep_sst_rsync + ALL + DEPENDS ${wsrep_sst_rsync_wan} + ) + INSTALL( + FILES ${wsrep_sst_rsync_wan} + DESTINATION ${INSTALL_BINDIR} + COMPONENT Server + ) FOREACH(file ${WSREP_SOURCE}) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh @@ -379,7 +395,6 @@ ELSE() COMPONENT ${${file}_COMPONENT} ) ENDFOREACH() - ENDIF() # Install libgcc as mylibgcc.a diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index a8f671de2247bee3cd82142cb94a2882a42f4fdb..e160bf5c77649d4c502f4c0665b18565c5ea8dda 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -35,18 +35,24 @@ case "$1" in # # Break address string into host:port/path parts # - readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} - if [ ${WSREP_SST_OPT_HOST:0:1} = '[' ] - then - # IPv6 notation - readonly WSREP_SST_OPT_HOST_UNESCAPED=${WSREP_SST_OPT_HOST:1:-1} - else - readonly WSREP_SST_OPT_HOST_UNESCAPED=${WSREP_SST_OPT_HOST} - fi - readonly WSREP_SST_OPT_PORT=$(echo $WSREP_SST_OPT_ADDR | \ - cut -d ']' -f 2 | cut -s -d ':' -f 2 | cut -d '/' -f 1) + case "${WSREP_SST_OPT_ADDR}" in + \[*) + # IPv6 + addr_no_bracket=${WSREP_SST_OPT_ADDR#\[} + readonly WSREP_SST_OPT_HOST_UNESCAPED=${addr_no_bracket%%\]*} + readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]" + ;; + *) + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} + readonly WSREP_SST_OPT_HOST_UNESCAPED=$WSREP_SST_OPT_HOST + ;; + esac + remain=${WSREP_SST_OPT_ADDR#${WSREP_SST_OPT_HOST}} + remain=${remain#:} + readonly WSREP_SST_OPT_ADDR_PORT=${remain%%/*} + remain=${remain#*/} + readonly WSREP_SST_OPT_MODULE=${remain%%/*} readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/} - readonly WSREP_SST_OPT_MODULE=${WSREP_SST_OPT_PATH%%/*} remain=${WSREP_SST_OPT_PATH#*/} readonly WSREP_SST_OPT_LSN=${remain%%/*} remain=${remain#*/} @@ -126,6 +132,17 @@ done readonly WSREP_SST_OPT_BYPASS readonly WSREP_SST_OPT_BINLOG +if [ -n "${WSREP_SST_OPT_ADDR_PORT:-}" ]; then + if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then + if [ "$WSREP_SST_OPT_PORT" != "$WSREP_SST_OPT_ADDR_PORT" ]; then + echo "WSREP_SST: [ERROR] port in --port=$WSREP_SST_OPT_PORT differs from port in --address=$WSREP_SST_OPT_ADDR" >&2 + exit 2 + fi + else + readonly WSREP_SST_OPT_PORT="$WSREP_SST_OPT_ADDR_PORT" + fi +fi + # try to use my_print_defaults, mysql and mysqldump that come with the sources # (for MTR suite) SCRIPTS_DIR="$(cd $(dirname "$0"); pwd -P)" diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 9e3fc54290d5f8c2940b9de5a764790236b5200a..549161aa8f32e2906fb97648627b1af53698ea1f 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -179,12 +179,26 @@ get_transfer() wsrep_log_info "Using netcat as streamer" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if nc -h 2>&1 | grep -q ncat;then + # Ncat tcmd="nc -l ${TSST_PORT}" - else + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat tcmd="nc -dl ${TSST_PORT}" + else + # traditional netcat + tcmd="nc -l -p ${TSST_PORT}" fi else - tcmd="nc ${REMOTEIP} ${TSST_PORT}" + if nc -h 2>&1 | grep -q ncat;then + # Ncat + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + else + # traditional netcat + tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}" + fi fi else tfmt='socat' diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index 358247359e6fbadcc789077562344ed552e12974..faa3f10639b6f9fc582f3bcd5dfdec1cf240223e 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -108,22 +108,21 @@ then DROP PREPARE stmt;" fi -# Retrieve the donor's @@global.gtid_binlog_state. -GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" |\ -$MYSQL_CLIENT $AUTH -S$WSREP_SST_OPT_SOCKET --disable-reconnect --connect_timeout=10 |\ -tail -1 | awk -F ' ' '{ print $2 }') - MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\ "$AUTH -h${WSREP_SST_OPT_HOST_UNESCAPED} "\ "-P$WSREP_SST_OPT_PORT --disable-reconnect --connect_timeout=10" # Check if binary logging is enabled on the joiner node. # Note: SELECT cannot be used at this point. -LOG_BIN=$(echo "SHOW VARIABLES LIKE 'log_bin'" | $MYSQL |\ +LOG_BIN=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'log_bin'" | $MYSQL |\ tail -1 | awk -F ' ' '{ print $2 }') # Check the joiner node's server version. -SERVER_VERSION=$(echo "SHOW VARIABLES LIKE 'version'" | $MYSQL |\ +SERVER_VERSION=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'version'" | $MYSQL |\ +tail -1 | awk -F ' ' '{ print $2 }') + +# Retrieve the donor's @@global.gtid_binlog_state. +GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" | $MYSQL |\ tail -1 | awk -F ' ' '{ print $2 }') RESET_MASTER="" @@ -131,7 +130,7 @@ SET_GTID_BINLOG_STATE="" SQL_LOG_BIN_OFF="" # Safety check -if echo $SERVER_VERSION | grep '^10.1' > /dev/null +if [ "${SERVER_VERSION%%.*}" != '5' ] then # If binary logging is enabled on the joiner node, we need to copy donor's # gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be @@ -146,7 +145,7 @@ then fi # NOTE: we don't use --routines here because we're dumping mysql.proc table -MYSQLDUMP="$MYSQLDUMP $AUTH -S$WSREP_SST_OPT_SOCKET \ +MYSQLDUMP="$MYSQLDUMP $WSREP_SST_OPT_CONF $AUTH -S$WSREP_SST_OPT_SOCKET \ --add-drop-database --add-drop-table --skip-add-locks --create-options \ --disable-keys --extended-insert --skip-lock-tables --quick --set-charset \ --skip-comments --flush-privileges --all-databases --events" diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 64dd182e2f2f5b3c139e2d0272d05e51f9311772..00efdaeebcf17febbbab4ea9c5d4b36791c6761e 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -268,13 +268,26 @@ get_transfer() wsrep_log_info "Using netcat as streamer" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if nc -h 2>&1 | grep -q ncat; then + # Ncat tcmd="nc $sockopt -l ${TSST_PORT}" - else + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat tcmd="nc $sockopt -dl ${TSST_PORT}" + else + # traditional netcat + tcmd="nc $sockopt -l -p ${TSST_PORT}" fi else - # netcat doesn't understand [] around IPv6 address - tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}" + if nc -h 2>&1 | grep -q ncat;then + # Ncat + tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}" + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat + tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}" + else + # traditional netcat + tcmd="nc -q0 ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}" + fi fi else tfmt='socat' @@ -644,7 +657,7 @@ wait_for_listen() for i in {1..300} do - LSOF_OUT=$(lsof -sTCP:LISTEN -i TCP:${PORT} -a -c nc -c socat -F c) + LSOF_OUT=$(lsof -sTCP:LISTEN -i TCP:${PORT} -a -c nc -c socat -F c 2> /dev/null || :) [ -n "${LSOF_OUT}" ] && break sleep 0.2 done diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh index 867aab622ed04a5ee62f93b34627c3aa3744263e..5bf380a81449462d35e01f9f8bad733158454e62 100644 --- a/scripts/wsrep_sst_xtrabackup.sh +++ b/scripts/wsrep_sst_xtrabackup.sh @@ -144,12 +144,26 @@ get_transfer() wsrep_log_info "Using netcat as streamer" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if nc -h 2>&1 | grep -q ncat;then + # Ncat tcmd="nc -l ${TSST_PORT}" - else + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat tcmd="nc -dl ${TSST_PORT}" + else + # traditional netcat + tcmd="nc -l -p ${TSST_PORT}" fi else - tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}" + if nc -h 2>&1 | grep -q ncat;then + # Ncat + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + elif nc -h 2>&1 | grep -q -- '-d\>';then + # Debian netcat + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + else + # traditional netcat + tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}" + fi fi else tfmt='socat' @@ -394,7 +408,6 @@ if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' fi read_cnf -setup_ports get_stream get_transfer diff --git a/sql-common/client.c b/sql-common/client.c index da18a0fdea1155f137912c03488b93efcd627cab..b1c2d9cf4e2bcc55c8a8f7567e18a76e1d32643f 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1348,7 +1348,9 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, { uchar *pos; /* fields count may be wrong */ - DBUG_ASSERT((uint) (field - result) < fields); + if (field - result >= fields) + goto err; + cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); field->catalog= strmake_root(alloc,(char*) row->data[0], lengths[0]); field->db= strmake_root(alloc,(char*) row->data[1], lengths[1]); @@ -1366,12 +1368,7 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* Unpack fixed length parts */ if (lengths[6] != 12) - { - /* malformed packet. signal an error. */ - free_rows(data); /* Free old data */ - set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); - DBUG_RETURN(0); - } + goto err; pos= (uchar*) row->data[6]; field->charsetnr= uint2korr(pos); @@ -1398,6 +1395,8 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* old protocol, for backward compatibility */ for (row=data->data; row ; row = row->next,field++) { + if (field - result >= fields) + goto err; cli_fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5); field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]); field->name= strdup_root(alloc,(char*) row->data[1]); @@ -1434,8 +1433,17 @@ unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, } } #endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */ + if (field - result < fields) + goto err; free_rows(data); /* Free old data */ DBUG_RETURN(result); + +err: + /* malformed packet. signal an error. */ + free_rows(data); + free_root(alloc, MYF(0)); + set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); + DBUG_RETURN(0); } /* Read all rows (fields or data) from server */ @@ -1504,7 +1512,7 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, else { cur->data[field] = to; - if (len > (ulong) (end_to - to)) + if (unlikely(len > (ulong)(end_to-to) || to > end_to)) { free_rows(result); set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); @@ -1576,7 +1584,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) } else { - if (len > (ulong) (end_pos - pos)) + if (unlikely(len > (ulong)(end_pos - pos) || pos > end_pos)) { set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate); return -1; @@ -1821,7 +1829,8 @@ static int ssl_verify_server_cert(Vio *vio, const char* server_hostname, const c */ #ifdef HAVE_X509_check_host - ret_validation= X509_check_host(server_cert, server_hostname, 0, 0, 0) != 1; + ret_validation= X509_check_host(server_cert, server_hostname, + strlen(server_hostname), 0, 0) != 1; #else subject= X509_get_subject_name(server_cert); cn_loc= X509_NAME_get_index_by_NID(subject, NID_commonName, -1); @@ -2511,10 +2520,14 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, if (mysql->client_flag & CLIENT_MULTI_STATEMENTS) mysql->client_flag|= CLIENT_MULTI_RESULTS; -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#ifdef HAVE_OPENSSL + if (mysql->options.ssl_key || mysql->options.ssl_cert || + mysql->options.ssl_ca || mysql->options.ssl_capath || + mysql->options.ssl_cipher) + mysql->options.use_ssl = 1; if (mysql->options.use_ssl) mysql->client_flag|= CLIENT_SSL; -#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY*/ +#endif /* HAVE_OPENSSL */ if (mpvio->db) mysql->client_flag|= CLIENT_CONNECT_WITH_DB; @@ -2737,7 +2750,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) *buf= mysql->net.read_pos; /* was it a request to change plugins ? */ - if (**buf == 254) + if (pkt_len == packet_error || **buf == 254) return (int)packet_error; /* if yes, this plugin shan't continue */ /* @@ -2922,7 +2935,7 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, compile_time_assert(CR_OK == -1); compile_time_assert(CR_ERROR == 0); - if (res > CR_OK && mysql->net.read_pos[0] != 254) + if (res > CR_OK && (mysql->net.last_errno || mysql->net.read_pos[0] != 254)) { /* the plugin returned an error. write it down in mysql, diff --git a/sql/contributors.h b/sql/contributors.h index 7369dcd141d4c3d157a36376b77423fb1c66c60c..a0d05af3fa6255a73e830fdca13014f4e9eafa0e 100644 --- a/sql/contributors.h +++ b/sql/contributors.h @@ -41,13 +41,12 @@ struct show_table_contributors_st show_table_contributors[]= { {"Alibaba Cloud", "https://www.alibabacloud.com/", "Platinum Sponsor of the MariaDB Foundation"}, {"Tencent Cloud", "https://cloud.tencent.com", "Platinum Sponsor of the MariaDB Foundation"}, {"Microsoft", "https://microsoft.com/", "Platinum Sponsor of the MariaDB Foundation"}, - {"MariaDB Corporation", "https://mariadb.com", "Founding member, Gold Sponsor of the MariaDB Foundation"}, + {"MariaDB Corporation", "https://mariadb.com", "Founding member, Platinum Sponsor of the MariaDB Foundation"}, {"Visma", "https://visma.com", "Gold Sponsor of the MariaDB Foundation"}, {"DBS", "https://dbs.com", "Gold Sponsor of the MariaDB Foundation"}, {"IBM", "https://www.ibm.com", "Gold Sponsor of the MariaDB Foundation"}, {"Nexedi", "https://www.nexedi.com", "Silver Sponsor of the MariaDB Foundation"}, {"Acronis", "http://www.acronis.com", "Silver Sponsor of the MariaDB Foundation"}, - {"Auttomattic", "https://automattic.com", "Bronze Sponsor of the MariaDB Foundation"}, {"Verkkokauppa.com", "https://www.verkkokauppa.com", "Bronze Sponsor of the MariaDB Foundation"}, {"Virtuozzo", "https://virtuozzo.com", "Bronze Sponsor of the MariaDB Foundation"}, {"Tencent Game DBA", "http://tencentdba.com/about", "Bronze Sponsor of the MariaDB Foundation"}, diff --git a/sql/events.cc b/sql/events.cc index cb81e98a254bad31fe6aaa0b879de85b06063749..b7b263971b3f75ecdaf4662e0f80dc7ffe12f4ff 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -462,8 +462,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); - - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); if (lock_object_name(thd, MDL_key::EVENT, parse_data->dbname.str, parse_data->name.str)) @@ -592,8 +591,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) DBUG_RETURN(TRUE); - - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* Turn off row binlogging of this statement and use statement-based so @@ -619,7 +617,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) #ifdef WITH_WSREP error: DBUG_RETURN(TRUE); -#endif +#endif /* WITH_WSREP */ } diff --git a/sql/field.cc b/sql/field.cc index 9bc1fcbffe84c2a111e24c7ddac3ed47f212b142..64c51677c0ffcab017ed30bb96096cfcabbbcdef 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5788,6 +5788,13 @@ static void calc_datetime_days_diff(MYSQL_TIME *ltime, long days) ltime->second) * 1000000LL + ltime->second_part); unpack_time(timediff, ltime); + /* + unpack_time() broke down hours into ltime members hour,day,month. + Mix them back to ltime->hour using the same factors + that pack_time()/unpack_time() use (i.e. 32 for month). + */ + ltime->hour+= (ltime->month * 32 + ltime->day) * 24; + ltime->month= ltime->day= 0; } ltime->time_type= MYSQL_TIMESTAMP_TIME; } diff --git a/sql/handler.cc b/sql/handler.cc index b2a00e48d659feb19f929e0b525792acae1bc095..1027a8b102df4bbf867ddb93cc3682a3ad8c1062 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2018, 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 @@ -794,7 +794,9 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, */ void ha_close_connection(THD* thd) { - plugin_foreach(thd, closecon_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, 0); + plugin_foreach_with_mask(thd, closecon_handlerton, + MYSQL_STORAGE_ENGINE_PLUGIN, + PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0); } static my_bool kill_handlerton(THD *thd, plugin_ref plugin, @@ -3637,12 +3639,15 @@ void handler::print_error(int error, myf errflag) if ((debug_assert_if_crashed_table || global_system_variables.log_warnings > 1)) { + THD *thd= ha_thd(); /* Log error to log before we crash or if extended warnings are requested */ errflag|= ME_NOREFRESH; + if (thd && thd->is_optimistic_slave_worker()) + errflag|= ME_LOG_AS_WARN; } - } + } /* if we got an OS error from a file-based engine, specify a path of error */ if (error < HA_ERR_FIRST && bas_ext()[0]) @@ -4273,18 +4278,6 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table, DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); } - -/* - Default implementation to support in-place alter table - and old online add/drop index API -*/ - -void handler::notify_table_changed() -{ - ha_create_partitioning_metadata(table->s->path.str, NULL, CHF_INDEX_FLAG); -} - - void Alter_inplace_info::report_unsupported_error(const char *not_supported, const char *try_instead) { @@ -4383,7 +4376,7 @@ handler::ha_create_partitioning_metadata(const char *name, */ DBUG_ASSERT(m_lock_type == F_UNLCK || (!old_name && strcmp(name, table_share->path.str))); - mark_trx_read_write(); + return create_partitioning_metadata(name, old_name, action_flag); } @@ -5769,8 +5762,6 @@ static int write_locked_table_maps(THD *thd) typedef bool Log_func(THD*, TABLE*, bool, const uchar*, const uchar*); -static int check_wsrep_max_ws_rows(); - static int binlog_log_row(TABLE* table, const uchar *before_record, const uchar *after_record, @@ -5824,13 +5815,6 @@ static int binlog_log_row(TABLE* table, bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE || table->file->has_transactions(); error= (*log_func)(thd, table, has_trans, before_record, after_record); - - /* - Now that the record has been logged, increment wsrep_affected_rows and - also check whether its within the allowable limits (wsrep_max_ws_rows). - */ - if (error == 0) - error= check_wsrep_max_ws_rows(); } } return error ? HA_ERR_RBR_LOGGING_FAILED : 0; @@ -5941,30 +5925,6 @@ int handler::ha_reset() } -static int check_wsrep_max_ws_rows() -{ -#ifdef WITH_WSREP - if (wsrep_max_ws_rows) - { - THD *thd= current_thd; - - if (!WSREP(thd)) - return 0; - - thd->wsrep_affected_rows++; - if (thd->wsrep_exec_mode != REPL_RECV && - thd->wsrep_affected_rows > wsrep_max_ws_rows) - { - trans_rollback_stmt(thd) || trans_rollback(thd); - my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); - return ER_ERROR_DURING_COMMIT; - } - } -#endif /* WITH_WSREP */ - return 0; -} - - int handler::ha_write_row(uchar *buf) { int error; @@ -6209,6 +6169,12 @@ void ha_fake_trx_id(THD *thd) DBUG_VOID_RETURN; } + if (thd->wsrep_ws_handle.trx_id != WSREP_UNDEFINED_TRX_ID) + { + WSREP_DEBUG("fake trx id skipped: %lu", thd->wsrep_ws_handle.trx_id); + DBUG_VOID_RETURN; + } + /* Try statement transaction if standard one is not set. */ THD_TRANS *trans= (thd->transaction.all.ha_list) ? &thd->transaction.all : &thd->transaction.stmt; diff --git a/sql/handler.h b/sql/handler.h index 68de7563d8bb46bfddf0664c0fd4477c36383623..a047f276349761af49a3ea5151dd9df056940155 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3851,7 +3851,7 @@ class handler :public Sql_alloc @note No errors are allowed during notify_table_changed(). */ - virtual void notify_table_changed(); + virtual void notify_table_changed() { } public: /* End of On-line/in-place ALTER TABLE interface. */ diff --git a/sql/item.cc b/sql/item.cc index 2cc45dc60109d9efb8abbfc3520c2d8e228317ad..e23829c750cdd8244b7d7daedd31d7eaf4378b3c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -166,19 +166,21 @@ bool Item::get_time_with_conversion(THD *thd, MYSQL_TIME *ltime, - truncate the YYYYMMDD part - add (MM*33+DD)*24 to hours - add (MM*31+DD)*24 to hours - Let's return NULL here, to disallow equal field propagation. + Let's return TRUE here, to disallow equal field propagation. Note, If we start to use this method in more pieces of the code other - than eqial field propagation, we should probably return - NULL only if some flag in fuzzydate is set. + than equal field propagation, we should probably return + TRUE only if some flag in fuzzydate is set. */ - return (null_value= true); + return true; } if (datetime_to_time_with_warn(thd, ltime, <ime2, TIME_SECOND_PART_DIGITS)) { /* - Time difference between CURRENT_DATE and ltime - did not fit into the supported TIME range + If the time difference between CURRENT_DATE and ltime + did not fit into the supported TIME range, then we set the + difference to the maximum possible value in the supported TIME range */ + DBUG_ASSERT(0); return (null_value= true); } *ltime= ltime2; @@ -470,7 +472,9 @@ Item::Item(THD *thd): maybe_null=null_value=with_sum_func=with_field=0; in_rollup= 0; with_subselect= 0; - /* Initially this item is not attached to any JOIN_TAB. */ + with_param= 0; + + /* Initially this item is not attached to any JOIN_TAB. */ join_tab_idx= MAX_TABLES; /* Put item in free list so that we can free all items at end */ @@ -512,6 +516,7 @@ Item::Item(THD *thd, Item *item): in_rollup(item->in_rollup), null_value(item->null_value), with_sum_func(item->with_sum_func), + with_param(item->with_param), with_field(item->with_field), fixed(item->fixed), is_autogenerated_name(item->is_autogenerated_name), @@ -1282,7 +1287,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) ltime, fuzzydate, field_name_or_null())) goto err; - break; + return null_value= false; } case REAL_RESULT: { @@ -1290,7 +1295,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) if (null_value || double_to_datetime_with_warn(value, ltime, fuzzydate, field_name_or_null())) goto err; - break; + return null_value= false; } case DECIMAL_RESULT: { @@ -1299,7 +1304,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) decimal_to_datetime_with_warn(res, ltime, fuzzydate, field_name_or_null())) goto err; - break; + return null_value= false; } case STRING_RESULT: { @@ -1309,15 +1314,20 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), ltime, fuzzydate)) goto err; - break; + return null_value= false; } default: + null_value= true; DBUG_ASSERT(0); } - return null_value= 0; - err: + return null_value|= make_zero_date(ltime, fuzzydate); +} + + +bool Item::make_zero_date(MYSQL_TIME *ltime, ulonglong fuzzydate) +{ /* if the item was not null and convertion failed, we return a zero date if allowed, otherwise - null. @@ -1339,7 +1349,7 @@ bool Item::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) */ ltime->time_type= MYSQL_TIMESTAMP_TIME; } - return null_value|= !(fuzzydate & TIME_FUZZY_DATES); + return !(fuzzydate & TIME_FUZZY_DATES); } bool Item::get_seconds(ulonglong *sec, ulong *sec_part) @@ -1421,6 +1431,9 @@ bool Item_sp_variable::fix_fields(THD *thd, Item **) max_length= it->max_length; decimals= it->decimals; unsigned_flag= it->unsigned_flag; + with_param= 1; + if (thd->lex->current_select->master_unit()->item) + thd->lex->current_select->master_unit()->item->with_param= 1; fixed= 1; collation.set(it->collation.collation, it->collation.derivation); @@ -3124,6 +3137,15 @@ my_decimal *Item_null::val_decimal(my_decimal *decimal_value) } +bool Item_null::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) +{ + // following assert is redundant, because fixed=1 assigned in constructor + DBUG_ASSERT(fixed == 1); + make_zero_date(ltime, fuzzydate); + return (null_value= true); +} + + Item *Item_null::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { return this; @@ -7176,6 +7198,7 @@ void Item_ref::set_properties() split_sum_func() doesn't try to change the reference. */ with_sum_func= (*ref)->with_sum_func; + with_param= (*ref)->with_param; with_field= (*ref)->with_field; fixed= 1; if (alias_name_used) @@ -7601,6 +7624,7 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg): Type_std_attributes::set(orig_item); maybe_null= orig_item->maybe_null; with_sum_func= orig_item->with_sum_func; + with_param= orig_item->with_param; with_field= orig_item->with_field; name= item_arg->name; name_length= item_arg->name_length; @@ -8447,10 +8471,10 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items) } else { - Field *tmp_field= field_arg->field; - /* charset doesn't matter here, it's to avoid sigsegv only */ - tmp_field= new Field_null(0, 0, Field::NONE, field_arg->field->field_name, - &my_charset_bin); + static uchar null_bit=1; + /* charset doesn't matter here */ + Field *tmp_field= new Field_string(0, 0, &null_bit, 1, Field::NONE, + field_arg->field->field_name, &my_charset_bin); if (tmp_field) { tmp_field->init(field_arg->field->table); diff --git a/sql/item.h b/sql/item.h index a9b8006cdf3c897ea658b716376591a5a8026552..139ce40b25b34f9a122f8ff14cb41a91bee01148 100644 --- a/sql/item.h +++ b/sql/item.h @@ -663,6 +663,12 @@ class Item: public Value_source, SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param); Field *create_tmp_field(bool group, TABLE *table, uint convert_int_length); + /* + This method is used if the item was not null but convertion to + TIME/DATE/DATETIME failed. We return a zero date if allowed, + otherwise - null. + */ + bool make_zero_date(MYSQL_TIME *ltime, ulonglong fuzzydate); public: /* @@ -694,6 +700,7 @@ class Item: public Value_source, of a query with ROLLUP */ bool null_value; /* if item is null */ bool with_sum_func; /* True if item contains a sum func */ + bool with_param; /* True if contains an SP parameter */ /** True if any item except Item_sum contains a field. Set during parsing. */ @@ -2564,6 +2571,7 @@ class Item_null :public Item_basic_constant longlong val_int(); String *val_str(String *str); my_decimal *val_decimal(my_decimal *); + bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); int save_in_field(Field *field, bool no_conversions); int save_safe_in_field(Field *field); bool send(Protocol *protocol, String *str); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4e2e5bd4cac6d824f9de94bdab9d952814459cfb..6ffd582c133068cabc84f33510e5baaacce4bfde 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1358,6 +1358,7 @@ bool Item_in_optimizer::fix_left(THD *thd) } eval_not_null_tables(NULL); with_sum_func= args[0]->with_sum_func; + with_param= args[0]->with_param || args[1]->with_param; with_field= args[0]->with_field; if ((const_item_cache= args[0]->const_item())) { @@ -1406,6 +1407,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref) with_subselect= 1; with_sum_func= with_sum_func || args[1]->with_sum_func; with_field= with_field || args[1]->with_field; + with_param= args[0]->with_param || args[1]->with_param; used_tables_and_const_cache_join(args[1]); fixed= 1; return FALSE; @@ -1955,6 +1957,7 @@ void Item_func_interval::fix_length_and_dec() used_tables_and_const_cache_join(row); not_null_tables_cache= row->not_null_tables(); with_sum_func= with_sum_func || row->with_sum_func; + with_param= with_param || row->with_param; with_field= with_field || row->with_field; } @@ -4573,6 +4576,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) List_iterator li(list); Item *item; uchar buff[sizeof(char*)]; // Max local vars in function + bool is_and_cond= functype() == Item_func::COND_AND_FUNC; not_null_tables_cache= 0; used_tables_and_const_cache_init(); @@ -4635,26 +4639,33 @@ Item_cond::fix_fields(THD *thd, Item **ref) (item= *li.ref())->check_cols(1)) return TRUE; /* purecov: inspected */ used_tables_cache|= item->used_tables(); - if (item->const_item()) + if (item->const_item() && !item->with_param && + !item->is_expensive() && !cond_has_datetime_is_null(item)) { - if (!item->is_expensive() && !cond_has_datetime_is_null(item) && - item->val_int() == 0) + if (item->val_int() == is_and_cond && top_level()) { /* - This is "... OR false_cond OR ..." + a. This is "... AND true_cond AND ..." + In this case, true_cond has no effect on cond_and->not_null_tables() + b. This is "... OR false_cond/null cond OR ..." In this case, false_cond has no effect on cond_or->not_null_tables() */ } else { /* - This is "... OR const_cond OR ..." + a. This is "... AND false_cond/null_cond AND ..." + The whole condition is FALSE/UNKNOWN. + b. This is "... OR const_cond OR ..." In this case, cond_or->not_null_tables()=0, because the condition const_cond might evaluate to true (regardless of whether some tables were NULL-complemented). */ + not_null_tables_cache= (table_map) 0; and_tables_cache= (table_map) 0; } + if (thd->is_error()) + return TRUE; } else { @@ -4666,6 +4677,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) } with_sum_func= with_sum_func || item->with_sum_func; + with_param= with_param || item->with_param; with_field= with_field || item->with_field; with_subselect|= item->has_subquery(); if (item->maybe_null) @@ -4681,30 +4693,36 @@ bool Item_cond::eval_not_null_tables(uchar *opt_arg) { Item *item; + bool is_and_cond= functype() == Item_func::COND_AND_FUNC; List_iterator li(list); not_null_tables_cache= (table_map) 0; and_tables_cache= ~(table_map) 0; while ((item=li++)) { table_map tmp_table_map; - if (item->const_item()) + if (item->const_item() && !item->with_param && + !item->is_expensive() && !cond_has_datetime_is_null(item)) { - if (!item->is_expensive() && !cond_has_datetime_is_null(item) && - item->val_int() == 0) + if (item->val_int() == is_and_cond && top_level()) { /* - This is "... OR false_cond OR ..." + a. This is "... AND true_cond AND ..." + In this case, true_cond has no effect on cond_and->not_null_tables() + b. This is "... OR false_cond/null cond OR ..." In this case, false_cond has no effect on cond_or->not_null_tables() */ } else { /* - This is "... OR const_cond OR ..." + a. This is "... AND false_cond/null_cond AND ..." + The whole condition is FALSE/UNKNOWN. + b. This is "... OR const_cond OR ..." In this case, cond_or->not_null_tables()=0, because the condition - some_cond_or might be true regardless of what tables are - NULL-complemented. + const_cond might evaluate to true (regardless of whether some tables + were NULL-complemented). */ + not_null_tables_cache= (table_map) 0; and_tables_cache= (table_map) 0; } } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 076e6da953cb08bf0d2406f1e7e7aa514eb859c2..03f234ad1e49e5346ba1bd5c4ed49be3cb967e0d 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -330,6 +330,7 @@ class Item_in_optimizer: public Item_bool_func bool is_null(); longlong val_int(); void cleanup(); + enum Functype functype() const { return IN_OPTIMIZER_FUNC; } const char *func_name() const { return ""; } Item_cache **get_cache() { return &cache; } void keep_top_level_cache(); @@ -347,6 +348,10 @@ class Item_in_optimizer: public Item_bool_func void reset_cache() { cache= NULL; } virtual void print(String *str, enum_query_type query_type); void restore_first_argument(); + Item* get_wrapped_in_subselect_item() + { + return args[1]; + } }; @@ -1312,6 +1317,13 @@ class cmp_item_sort_string :public cmp_item_string { value_res= item->val_str(&value); m_null_value= item->null_value; + // Make sure to cache the result String inside "value" + if (value_res && value_res != &value) + { + if (value.copy(*value_res)) + value.set("", 0, item->collation.collation); + value_res= &value; + } } int cmp(Item *arg) { @@ -2258,6 +2270,11 @@ class Item_equal: public Item_bool_func void sort(Item_field_cmpfunc compare, void *arg); void fix_length_and_dec(); bool fix_fields(THD *thd, Item **ref); + void cleanup() + { + delete eval_item; + eval_item= NULL; + } void update_used_tables(); COND *build_equal_items(THD *thd, COND_EQUAL *inherited, bool link_item_fields, diff --git a/sql/item_func.cc b/sql/item_func.cc index 0700d71a396e2b43e366b29d30850217cba0e572..05a34a9a24a9e71ba7b5764b9cd418e0f0aa67e4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -133,6 +133,7 @@ void Item_func::sync_with_sum_func_and_with_field(List &list) { with_sum_func|= item->with_sum_func; with_field|= item->with_field; + with_param|= item->with_param; } } @@ -226,6 +227,7 @@ Item_func::fix_fields(THD *thd, Item **ref) maybe_null=1; with_sum_func= with_sum_func || item->with_sum_func; + with_param= with_param || item->with_param; with_field= with_field || item->with_field; used_tables_and_const_cache_join(item); with_subselect|= item->has_subquery(); @@ -3506,6 +3508,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, func->maybe_null=1; func->with_sum_func= func->with_sum_func || item->with_sum_func; func->with_field= func->with_field || item->with_field; + func->with_param= func->with_param || item->with_param; func->with_subselect|= item->with_subselect; func->used_tables_and_const_cache_join(item); f_args.arg_type[i]=item->result_type(); diff --git a/sql/item_func.h b/sql/item_func.h index 1209fc5cdd8624353badbfc4ee10ecc49e4b3074..3219c813821ad2b48b928df3c24d038ba8f7e42f 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -67,23 +67,26 @@ class Item_func :public Item_func_or_sum NOW_FUNC, TRIG_COND_FUNC, SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC, EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC, - NEG_FUNC, GSYSVAR_FUNC, DYNCOL_FUNC }; + NEG_FUNC, GSYSVAR_FUNC, IN_OPTIMIZER_FUNC, DYNCOL_FUNC }; enum Type type() const { return FUNC_ITEM; } virtual enum Functype functype() const { return UNKNOWN_FUNC; } Item_func(THD *thd): Item_func_or_sum(thd), allowed_arg_cols(1) { with_sum_func= 0; with_field= 0; + with_param= 0; } Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a), allowed_arg_cols(1) { with_sum_func= a->with_sum_func; + with_param= a->with_param; with_field= a->with_field; } Item_func(THD *thd, Item *a, Item *b): Item_func_or_sum(thd, a, b), allowed_arg_cols(1) { with_sum_func= a->with_sum_func || b->with_sum_func; + with_param= a->with_param || b->with_param; with_field= a->with_field || b->with_field; } Item_func(THD *thd, Item *a, Item *b, Item *c): @@ -91,6 +94,7 @@ class Item_func :public Item_func_or_sum { with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func; with_field= a->with_field || b->with_field || c->with_field; + with_param= a->with_param || b->with_param || c->with_param; } Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d): Item_func_or_sum(thd, a, b, c, d), allowed_arg_cols(1) @@ -99,6 +103,8 @@ class Item_func :public Item_func_or_sum c->with_sum_func || d->with_sum_func; with_field= a->with_field || b->with_field || c->with_field || d->with_field; + with_param= a->with_param || b->with_param || + c->with_param || d->with_param; } Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e): Item_func_or_sum(thd, a, b, c, d, e), allowed_arg_cols(1) @@ -107,6 +113,8 @@ class Item_func :public Item_func_or_sum c->with_sum_func || d->with_sum_func || e->with_sum_func; with_field= a->with_field || b->with_field || c->with_field || d->with_field || e->with_field; + with_param= a->with_param || b->with_param || + c->with_param || d->with_param || e->with_param; } Item_func(THD *thd, List &list): Item_func_or_sum(thd, list), allowed_arg_cols(1) @@ -2217,6 +2225,8 @@ class Item_func_uuid_short :public Item_int_func Item_func_uuid_short(THD *thd): Item_int_func(thd) {} const char *func_name() const { return "uuid_short"; } longlong val_int(); + bool const_item() const { return false; } + table_map used_tables() const { return RAND_TABLE_BIT; } void fix_length_and_dec() { max_length= 21; unsigned_flag=1; } bool check_vcol_func_processor(uchar *int_arg) diff --git a/sql/item_row.cc b/sql/item_row.cc index 97f75c4b4cf1ac622ed5b39ef469b31b11416e5e..8c6edacad7f50b639bfaec90c13787e57984d249 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -64,6 +64,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref) with_sum_func= with_sum_func || item->with_sum_func; with_field= with_field || item->with_field; with_subselect|= item->with_subselect; + with_param|= item->with_param; } fixed= 1; return FALSE; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index cd47257a77b0945ca956fa4d33f9a408a57eff0d..db1ba15214fb2bcefd00b3ffae0671a4698c61ab 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -318,7 +318,7 @@ String *Item_aes_crypt::val_str(String *str2) { DBUG_ASSERT(fixed == 1); StringBuffer<80> user_key_buf; - String *sptr= args[0]->val_str(&str_value); + String *sptr= args[0]->val_str(&tmp_value); String *user_key= args[1]->val_str(&user_key_buf); uint32 aes_length; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index e19efd312295ba4b0cae2efecc0184f2daf0b3e4..49faed2fec17ab9fffb4f90ebe60d1dce7f2ad3c 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -202,6 +202,7 @@ class Item_aes_crypt :public Item_str_binary_checksum_func protected: int what; + String tmp_value; public: Item_aes_crypt(THD *thd, Item *a, Item *b) :Item_str_binary_checksum_func(thd, a, b) {} @@ -211,8 +212,8 @@ class Item_aes_crypt :public Item_str_binary_checksum_func class Item_func_aes_encrypt :public Item_aes_crypt { public: - Item_func_aes_encrypt(THD *thd, Item *a, Item *b): - Item_aes_crypt(thd, a, b) {} + Item_func_aes_encrypt(THD *thd, Item *a, Item *b) + :Item_aes_crypt(thd, a, b) {} void fix_length_and_dec(); const char *func_name() const { return "aes_encrypt"; } }; @@ -1241,6 +1242,8 @@ class Item_func_uuid: public Item_str_func DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); fix_char_length(MY_UUID_STRING_LENGTH); } + bool const_item() const { return false; } + table_map used_tables() const { return RAND_TABLE_BIT; } const char *func_name() const{ return "uuid"; } String *val_str(String *); bool check_vcol_func_processor(uchar *int_arg) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 7dbaf313ad9359252ebdad41d18c31f17cecb67b..b275f749f250c5983ea8b7eb8a5f26b9a3ea4bc4 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1818,7 +1818,7 @@ Item_in_subselect::single_value_transformer(JOIN *join) Item* join_having= join->having ? join->having : join->tmp_having; if (!(join_having || select_lex->with_sum_func || select_lex->group_list.elements) && - select_lex->table_list.elements == 0 && + select_lex->table_list.elements == 0 && !join->conds && !select_lex->master_unit()->is_union()) { Item *where_item= (Item*) select_lex->item_list.head(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0e2e9f0795d75b10e2b5a6e886f6eb7d48048d46..b4e31ba012f26d5543167f11a59a84d0b044d75d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1159,6 +1159,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref) return TRUE; set_if_bigger(decimals, args[i]->decimals); with_subselect|= args[i]->with_subselect; + with_param|= args[i]->with_param; } result_field=0; max_length=float_length(decimals); @@ -1190,6 +1191,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) return TRUE; Type_std_attributes::set(args[0]); with_subselect= args[0]->with_subselect; + with_param= args[0]->with_param; Item *item2= item->real_item(); if (item2->type() == Item::FIELD_ITEM) @@ -3361,6 +3363,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) args[i]->check_cols(1)) return TRUE; with_subselect|= args[i]->with_subselect; + with_param|= args[i]->with_param; } /* skip charset aggregation for order columns */ diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 4a94c3a5f89dd6c6155e8a53dbf70bd359ac0498..44105bd4a1257b0a2b16061edb27c1e311328230 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -702,7 +702,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, { const char *end=str+length; uint i; - long msec_length= 0; + long field_length= 0; while (str != end && !my_isdigit(cs,*str)) str++; @@ -713,7 +713,8 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, const char *start= str; for (value= 0; str != end && my_isdigit(cs, *str); str++) value= value*10 + *str - '0'; - msec_length= 6 - (str - start); + if ((field_length= str - start) >= 20) + return true; values[i]= value; while (str != end && !my_isdigit(cs,*str)) str++; @@ -728,8 +729,13 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, } } - if (transform_msec && msec_length > 0) - values[count - 1] *= (long) log_10_int[msec_length]; + if (transform_msec && field_length > 0) + { + if (field_length < 6) + values[count - 1] *= log_10_int[6 - field_length]; + else if (field_length > 6) + values[count - 1] /= log_10_int[field_length - 6]; + } return (str != end); } diff --git a/sql/log.cc b/sql/log.cc index 29f8c5639cfcfcbe0010082f647e6dbcb20d65b0..bcfaf5174daac9496664f612b269d7b7ca14a721 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2576,7 +2576,7 @@ bool MYSQL_LOG::open( File file= -1; my_off_t seek_offset; bool is_fifo = false; - int open_flags= O_CREAT | O_BINARY; + int open_flags= O_CREAT | O_BINARY | O_CLOEXEC; DBUG_ENTER("MYSQL_LOG::open"); DBUG_PRINT("enter", ("log_type: %d", (int) log_type_arg)); @@ -3296,7 +3296,7 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, ".index", opt); if ((index_file_nr= mysql_file_open(m_key_file_log_index, index_file_name, - O_RDWR | O_CREAT | O_BINARY, + O_RDWR | O_CREAT | O_BINARY | O_CLOEXEC, MYF(MY_WME))) < 0 || mysql_file_sync(index_file_nr, MYF(MY_WME)) || init_io_cache(&index_file, index_file_nr, @@ -8967,14 +8967,14 @@ int TC_LOG_MMAP::open(const char *opt_name) tc_log_page_size= my_getpagesize(); fn_format(logname,opt_name,mysql_data_home,"",MY_UNPACK_FILENAME); - if ((fd= mysql_file_open(key_file_tclog, logname, O_RDWR, MYF(0))) < 0) + if ((fd= mysql_file_open(key_file_tclog, logname, O_RDWR | O_CLOEXEC, MYF(0))) < 0) { if (my_errno != ENOENT) goto err; if (using_heuristic_recover()) return 1; if ((fd= mysql_file_create(key_file_tclog, logname, CREATE_MODE, - O_RDWR, MYF(MY_WME))) < 0) + O_RDWR | O_CLOEXEC, MYF(MY_WME))) < 0) goto err; inited=1; file_length= opt_tc_log_size; diff --git a/sql/log_event.cc b/sql/log_event.cc index 81bc683625fe4c6ecaef608225a86e39e171dffa..e70d97c54c011525ec2c88823a6314cfccb22b6a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 @@ -1311,6 +1311,8 @@ bool Log_event::write_header(ulong event_data_length) */ log_pos= writer->pos() + data_written; + + DBUG_EXECUTE_IF("dbug_master_binlog_over_2GB", log_pos += (1ULL <<31);); } now= get_time(); // Query start time @@ -3773,6 +3775,24 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, db= (char *)start; query= (char *)(start + db_len + 1); q_len= data_len - db_len -1; + + if (data_len && (data_len < db_len || + data_len < q_len || + data_len != (db_len + q_len + 1))) + { + q_len= 0; + query= NULL; + DBUG_VOID_RETURN; + } + + uint32 max_length= uint32(event_len - ((const char*)(end + db_len + 1) - + (buf - common_header_len))); + if (q_len != max_length) + { + q_len= 0; + query= NULL; + DBUG_VOID_RETURN; + } /** Append the db length at the end of the buffer. This will be used by Query_cache::send_result_to_client() in case the query cache is On. @@ -4239,6 +4259,20 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, you. */ thd->catalog= catalog_len ? (char *) catalog : (char *)""; + + int len_error; + size_t valid_len= system_charset_info->cset->well_formed_len(system_charset_info, + db, db + db_len, db_len, &len_error); + + if (valid_len != db_len) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid database name in Query event."); + thd->is_slave_error= true; + goto end; + } + new_db.length= db_len; new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); thd->set_db(new_db.str, new_db.length); /* allocates a copy of 'db' */ @@ -4380,7 +4414,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, } else thd->variables.collation_database= thd->db_charset; - + /* Record any GTID in the same transaction, so slave state is transactionally consistent. @@ -4922,7 +4956,13 @@ int Start_log_event_v3::do_apply_event(rpl_group_info *rgi) */ break; default: - /* this case is impossible */ + /* + This case is not expected. It can be either an event corruption or an + unsupported binary log version. + */ + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Binlog version not supported"); DBUG_RETURN(1); } DBUG_RETURN(error); @@ -5829,6 +5869,9 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, fields = (char*)field_lens + num_fields; table_name = fields + field_block_len; + if (strlen(table_name) > NAME_LEN) + goto err; + db = table_name + table_name_len + 1; DBUG_EXECUTE_IF ("simulate_invalid_address", db_len = data_len;); @@ -7805,6 +7848,13 @@ User_var_log_event(const char* buf, uint event_len, buf+= description_event->common_header_len + description_event->post_header_len[USER_VAR_EVENT-1]; name_len= uint4korr(buf); + /* Avoid reading out of buffer */ + if ((buf - buf_start) + UV_NAME_LEN_SIZE + name_len > event_len) + { + error= true; + goto err; + } + name= (char *) buf + UV_NAME_LEN_SIZE; /* @@ -7862,6 +7912,11 @@ User_var_log_event(const char* buf, uint event_len, we keep the flags set to UNDEF_F. */ uint bytes_read= ((val + val_len) - buf_start); + if (bytes_read > event_len) + { + error= true; + goto err; + } if ((data_written - bytes_read) > 0) { flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + @@ -8076,7 +8131,12 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) } if (!(charset= get_charset(charset_number, MYF(MY_WME)))) + { + rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid character set for User var event"); DBUG_RETURN(1); + } LEX_STRING user_var_name; user_var_name.str= name; user_var_name.length= name_len; @@ -8091,12 +8151,26 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) { switch (type) { case REAL_RESULT: + if (val_len != 8) + { + rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } float8get(real_val, val); it= new (thd->mem_root) Item_float(thd, real_val, 0); val= (char*) &real_val; // Pointer to value in native format val_len= 8; break; case INT_RESULT: + if (val_len != 8) + { + rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } int_val= (longlong) uint8korr(val); it= new (thd->mem_root) Item_int(thd, int_val); val= (char*) &int_val; // Pointer to value in native format @@ -8104,6 +8178,13 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) break; case DECIMAL_RESULT: { + if (val_len < 3) + { + rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } Item_decimal *dec= new (thd->mem_root) Item_decimal(thd, (uchar*) val+2, val[0], val[1]); it= dec; val= (char *)dec->val_decimal(NULL); @@ -9470,6 +9551,14 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); DBUG_PRINT("debug", ("m_width=%lu", m_width)); + + /* Avoid reading out of buffer */ + if (ptr_after_width + (m_width + 7) / 8 > (uchar*)buf + event_len) + { + m_cols.bitmap= NULL; + DBUG_VOID_RETURN; + } + /* if my_bitmap_init fails, catched in is_valid() */ if (likely(!my_bitmap_init(&m_cols, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, @@ -9519,7 +9608,12 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, const uchar* const ptr_rows_data= (const uchar*) ptr_after_width; - size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf); + size_t const read_size= ptr_rows_data - (const unsigned char *) buf; + if (read_size > event_len) + { + DBUG_VOID_RETURN; + } + size_t const data_size= event_len - read_size; DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu", m_table_id, m_flags, m_width, (ulong) data_size)); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index abd489773f6d26475384e6b26043e8ce7c40af1b..d2b4470bbf93ed5b2a63ef955dbe59372c30b192 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2007, 2016, Oracle and/or its affiliates. +/* Copyright (c) 2007, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 @@ -1231,6 +1232,13 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); DBUG_PRINT("debug", ("m_width=%lu", m_width)); + /* Avoid reading out of buffer */ + if (ptr_after_width + m_width > (uchar *)buf + event_len) + { + m_cols.bitmap= NULL; + DBUG_VOID_RETURN; + } + /* if my_bitmap_init fails, catched in is_valid() */ if (likely(!my_bitmap_init(&m_cols, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, diff --git a/sql/mdl.cc b/sql/mdl.cc index 56515d42c58a8b7e79b635e7eec0a647d819bc24..86fc5fa39fcd856faf3871e3ddcbebcf1020bc70 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -674,7 +674,7 @@ int mdl_iterate(int (*callback)(MDL_ticket *ticket, void *arg), void *arg) my_hash_value_type mdl_hash_function(CHARSET_INFO *cs, const uchar *key, size_t length) { - MDL_key *mdl_key= (MDL_key*) (key - offsetof(MDL_key, m_ptr)); + MDL_key *mdl_key= (MDL_key*) (key - my_offsetof(MDL_key, m_ptr)); return mdl_key->hash_value(); } diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc index ae314d826a00be497b6e38b8c710ad54de87e100..f26a437a25a523475ca505dfeb502118a8ecf205 100644 --- a/sql/mf_iocache_encr.cc +++ b/sql/mf_iocache_encr.cc @@ -49,8 +49,8 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count) if (pos_in_file == info->end_of_file) { - info->read_pos= info->read_end= info->buffer; - info->pos_in_file= pos_in_file; + /* reading past EOF should not empty the cache */ + info->read_pos= info->read_end; info->error= 0; DBUG_RETURN(MY_TEST(Count)); } @@ -145,9 +145,10 @@ static int my_b_encr_write(IO_CACHE *info, const uchar *Buffer, size_t Count) if (info->seek_not_done) { - DBUG_ASSERT(info->pos_in_file == 0); + DBUG_ASSERT(info->pos_in_file % info->buffer_length == 0); + size_t wpos= info->pos_in_file / info->buffer_length * crypt_data->block_length; - if ((mysql_file_seek(info->file, 0, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)) + if ((mysql_file_seek(info->file, wpos, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)) { info->error= -1; DBUG_RETURN(1); diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 120b4c103addbee63705b862cc36f73da570d1e5..e0f6ed4daa8e94811d9dd1599e18e462fbf36c0c 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -195,7 +195,7 @@ int main(int argc, char **argv) die("database creation failed"); } - printf("Creation of the database was successfull"); + printf("Creation of the database was successful"); return 0; } diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 36de05e54e4483d124d562812105aea8b284692a..9bb608092059dbea3d0878a05257b09b30b5bf9d 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -146,6 +146,11 @@ static void die(const char *fmt, ...) exit(1); } +#define WRITE_LOG(fmt,...) {\ + char log_buf[1024]; \ + snprintf(log_buf,sizeof(log_buf), fmt, __VA_ARGS__);\ + WriteFile(logfile_handle,log_buf, strlen(log_buf), 0 , 0);\ +} /* spawn-like function to run subprocesses. @@ -187,17 +192,22 @@ static intptr_t run_tool(int wait_flag, const char *program,...) { char tmpdir[FN_REFLEN]; GetTempPath(FN_REFLEN, tmpdir); - sprintf_s(logfile_path, "%s\\mysql_upgrade_service.%s.log", tmpdir, + sprintf_s(logfile_path, "%smysql_upgrade_service.%s.log", tmpdir, opt_service); - logfile_handle= CreateFile(logfile_path, GENERIC_WRITE, FILE_SHARE_READ, - NULL, TRUNCATE_EXISTING, 0, NULL); - if (!logfile_handle) + SECURITY_ATTRIBUTES attr= {0}; + attr.nLength= sizeof(SECURITY_ATTRIBUTES); + attr.bInheritHandle= TRUE; + logfile_handle= CreateFile(logfile_path, FILE_APPEND_DATA, + FILE_SHARE_READ|FILE_SHARE_WRITE, &attr, CREATE_ALWAYS, 0, NULL); + if (logfile_handle == INVALID_HANDLE_VALUE) { die("Cannot open log file %s, windows error %u", logfile_path, GetLastError()); } } + WRITE_LOG("Executing %s\r\n", cmdline); + /* Start child process */ STARTUPINFO si= {0}; si.cb= sizeof(si); @@ -458,7 +468,7 @@ int main(int argc, char **argv) log("Phase 3/8: Starting mysqld for upgrade"); mysqld_process= (HANDLE)run_tool(P_NOWAIT, mysqld_path, defaults_file_param, "--skip-networking", "--skip-grant-tables", - "--enable-named-pipe", socket_param, NULL); + "--enable-named-pipe", socket_param,"--skip-slave-start", NULL); if (mysqld_process == INVALID_HANDLE_VALUE) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0de9d7a9f0b377e6c33b47e9e411351ec3b021c5..5bf5e3f73fcdb1a73352a5e367204d18ce0a8794 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2016, MariaDB + Copyright (c) 2008, 2018, MariaDB 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 @@ -111,7 +111,7 @@ #include #endif -#include +#include #define mysqld_charset &my_charset_latin1 @@ -540,7 +540,7 @@ bool max_user_connections_checking=0; Limit of the total number of prepared statements in the server. Is necessary to protect the server against out-of-memory attacks. */ -ulong max_prepared_stmt_count; +uint max_prepared_stmt_count; /** Current total number of prepared statements in the server. This number is exact, and therefore may not be equal to the difference between @@ -551,7 +551,7 @@ ulong max_prepared_stmt_count; two different connections, this counts as two distinct prepared statements. */ -ulong prepared_stmt_count=0; +uint prepared_stmt_count=0; ulong thread_id=1L,current_pid; ulong slow_launch_threads = 0; uint sync_binlog_period= 0, sync_relaylog_period= 0, @@ -3517,6 +3517,16 @@ void my_message_sql(uint error, const char *str, myf MyFlags) level= Sql_condition::WARN_LEVEL_WARN; func= sql_print_warning; } + else if (MyFlags & ME_LOG_AS_WARN) + { + /* + Typical use case is optimistic parallel slave where DA needs to hold + an error condition caused by the current error, but the error-log + level is relaxed to the warning one. + */ + level= Sql_condition::WARN_LEVEL_ERROR; + func= sql_print_warning; + } else { level= Sql_condition::WARN_LEVEL_ERROR; @@ -4287,11 +4297,20 @@ static int init_common_variables() /* connections and databases needs lots of files */ { - uint files, wanted_files, max_open_files; + uint files, wanted_files, max_open_files, min_tc_size, extra_files, + min_connections; + ulong org_max_connections, org_tc_size; + /* Number of files reserved for temporary files */ + extra_files= 30; + min_connections= 10; /* MyISAM requires two file handles per table. */ - wanted_files= (10 + max_connections + extra_max_connections + + wanted_files= (extra_files + max_connections + extra_max_connections + tc_size * 2); + min_tc_size= MY_MIN(tc_size, TABLE_OPEN_CACHE_MIN); + org_max_connections= max_connections; + org_tc_size= tc_size; + /* We are trying to allocate no less than max_connections*5 file handles (i.e. we are trying to set the limit so that they will @@ -4303,41 +4322,52 @@ static int init_common_variables() requested (value of wanted_files). */ max_open_files= MY_MAX(MY_MAX(wanted_files, - (max_connections + extra_max_connections)*5), - open_files_limit); + (max_connections + extra_max_connections)*5), + open_files_limit); files= my_set_max_open_files(max_open_files); + SYSVAR_AUTOSIZE_IF_CHANGED(open_files_limit, files, ulong); - if (files < wanted_files) - { - if (!open_files_limit) - { - /* - If we have requested too much file handles than we bring - max_connections in supported bounds. - */ - SYSVAR_AUTOSIZE(max_connections, - (ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2, max_connections)); - /* - Decrease tc_size according to max_connections, but - not below TABLE_OPEN_CACHE_MIN. Outer MY_MIN() ensures that we - never increase tc_size automatically (that could - happen if max_connections is decreased above). - */ - SYSVAR_AUTOSIZE(tc_size, - (ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2, - TABLE_OPEN_CACHE_MIN), tc_size)); - DBUG_PRINT("warning", - ("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", - files, max_connections, tc_size)); - if (global_system_variables.log_warnings > 1) - sql_print_warning("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", - files, max_connections, tc_size); - } - else if (global_system_variables.log_warnings) - sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); - } - SYSVAR_AUTOSIZE(open_files_limit, files); + if (files < wanted_files && global_system_variables.log_warnings) + sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); + + /* + If we have requested too much file handles than we bring + max_connections in supported bounds. Still leave at least + 'min_connections' connections + */ + SYSVAR_AUTOSIZE_IF_CHANGED(max_connections, + (ulong) MY_MAX(MY_MIN(files- extra_files- + min_tc_size*2, + max_connections), + min_connections), + ulong); + + /* + Decrease tc_size according to max_connections, but + not below min_tc_size. Outer MY_MIN() ensures that we + never increase tc_size automatically (that could + happen if max_connections is decreased above). + */ + SYSVAR_AUTOSIZE_IF_CHANGED(tc_size, + (ulong) MY_MIN(MY_MAX((files - extra_files - + max_connections) / 2, + min_tc_size), + tc_size), ulong); + DBUG_PRINT("warning", + ("Current limits: max_open_files: %u max_connections: %ld table_cache: %ld", + files, max_connections, tc_size)); + if (global_system_variables.log_warnings > 1 && + (max_connections < org_max_connections || + tc_size < org_tc_size)) + sql_print_warning("Changed limits: max_open_files: %u max_connections: %lu (was %lu) table_cache: %lu (was %lu)", + files, max_connections, org_max_connections, + tc_size, org_tc_size); } + /* + Max_connections and tc_cache are now set. + Now we can fix other variables depending on this variable. + */ + unireg_init(opt_specialflag); /* Set up extern variabels */ if (!(my_default_lc_messages= my_locale_by_name(lc_messages))) @@ -5511,8 +5541,7 @@ int mysqld_main(int argc, char **argv) orig_argc= argc; orig_argv= argv; my_getopt_use_args_separator= TRUE; - if (load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv)) - return 1; + load_defaults_or_exit(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv); my_getopt_use_args_separator= FALSE; defaults_argc= argc; defaults_argv= argv; @@ -5871,12 +5900,14 @@ int mysqld_main(int argc, char **argv) mysqld_port, MYSQL_COMPILATION_COMMENT); +#ifndef _WIN32 // try to keep fd=0 busy - if (!freopen(IF_WIN("NUL","/dev/null"), "r", stdin)) + if (!freopen("/dev/null", "r", stdin)) { // fall back on failure fclose(stdin); } +#endif #if defined(_WIN32) && !defined(EMBEDDED_LIBRARY) Service.SetRunning(); @@ -6461,7 +6492,7 @@ void handle_connections_sockets() #endif sd_notify(0, "READY=1\n" - "STATUS=Taking your SQL requests now..."); + "STATUS=Taking your SQL requests now...\n"); DBUG_PRINT("general",("Waiting for connections.")); MAYBE_BROKEN_SYSCALL; @@ -6679,7 +6710,7 @@ void handle_connections_sockets() set_current_thd(0); } sd_notify(0, "STOPPING=1\n" - "STATUS=Shutdown in progress"); + "STATUS=Shutdown in progress\n"); DBUG_VOID_RETURN; } diff --git a/sql/mysqld.h b/sql/mysqld.h index 0725d862553d09e4c2e279e8c1f8fa863f648f05..97ecf88978705735f720907c314203a3a834a43d 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -200,7 +200,7 @@ extern ulong slave_trans_retries; extern uint slave_net_timeout; extern int max_user_connections; extern ulong what_to_log,flush_time; -extern ulong max_prepared_stmt_count, prepared_stmt_count; +extern uint max_prepared_stmt_count, prepared_stmt_count; extern ulong open_files_limit; extern ulonglong binlog_cache_size, binlog_stmt_cache_size; extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index d7371fa7e3f239834ddfead3ac289d4406901a7c..89338928cb5c48c25864663424fac9619e412bb5 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -875,8 +875,10 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs) Make sure that create_tmp_table will not fail due to too long keys. See MDEV-7122. This check is performed inside create_tmp_table also and we must do it so that we know the table has keys created. + Make sure that the length of the key for the temp_table is atleast + greater than 0. */ - if (total_key_length > tmp_table_max_key_length() || + if (!total_key_length || total_key_length > tmp_table_max_key_length() || elements > tmp_table_max_key_parts()) DBUG_RETURN(FALSE); @@ -1006,6 +1008,10 @@ bool check_for_outer_joins(List *join_list) void find_and_block_conversion_to_sj(Item *to_find, List_iterator_fast &li) { + if (to_find->type() == Item::FUNC_ITEM && + ((Item_func*)to_find)->functype() == Item_func::IN_OPTIMIZER_FUNC) + to_find= ((Item_in_optimizer*)to_find)->get_wrapped_in_subselect_item(); + if (to_find->type() != Item::SUBSELECT_ITEM || ((Item_subselect *) to_find)->substype() != Item_subselect::IN_SUBS) return; @@ -3738,22 +3744,30 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) sjm= emb_sj_nest->sj_mat_info; thd= tab->join->thd; /* First the calls come to the materialization function */ - //List &item_list= emb_sj_nest->sj_subq_pred->unit->first_select()->item_list; - + DBUG_ASSERT(sjm->is_used); /* Set up the table to write to, do as select_union::create_result_table does */ sjm->sjm_table_param.init(); sjm->sjm_table_param.bit_fields_as_long= TRUE; - //List_iterator it(item_list); SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select(); - Item **p_item= subq_select->ref_pointer_array; - Item **p_end= p_item + subq_select->item_list.elements; - //while((right_expr= it++)) - for(;p_item != p_end; p_item++) - sjm->sjm_table_cols.push_back(*p_item, thd->mem_root); - + List_iterator it(subq_select->item_list); + Item *item; + while((item= it++)) + { + /* + This semi-join replaced the subquery (subq_select) and so on + re-executing it will not be prepared. To use the Items from its + select list we have to prepare (fix_fields) them + */ + if (!item->fixed && item->fix_fields(thd, it.ref())) + DBUG_RETURN(TRUE); + item= *(it.ref()); // it can be changed by fix_fields + DBUG_ASSERT(!item->name_length || item->name_length == strlen(item->name)); + sjm->sjm_table_cols.push_back(item, thd->mem_root); + } + sjm->sjm_table_param.field_count= subq_select->item_list.elements; sjm->sjm_table_param.force_not_null_cols= TRUE; @@ -5972,5 +5986,6 @@ bool JOIN::choose_tableless_subquery_plan() tmp_having= having; } } + exec_const_cond= conds; return FALSE; } diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 14f301e2d851f880bd204c29d58a34100ca1fd43..df0a733f1214c0fc5a5908141abf996b00500f86 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -2744,23 +2744,6 @@ bool partition_info::fix_column_value_functions(THD *thd, } -bool partition_info::error_if_requires_values() const -{ - switch (part_type) { - case NOT_A_PARTITION: - case HASH_PARTITION: - break; - case RANGE_PARTITION: - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN"); - return true; - case LIST_PARTITION: - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); - return true; - } - return false; -} - - /** Fix partition data from parser. @@ -3211,3 +3194,19 @@ bool check_partition_dirs(partition_info *part_info) } #endif /* WITH_PARTITION_STORAGE_ENGINE */ + +bool partition_info::error_if_requires_values() const +{ + switch (part_type) { + case NOT_A_PARTITION: + case HASH_PARTITION: + break; + case RANGE_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN"); + return true; + case LIST_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); + return true; + } + return false; +} diff --git a/sql/set_var.h b/sql/set_var.h index cf86ecf18fa3b9a73e55e06ede8c1abaab918fbc..203969d616912df8ba675b2cae7545ac2a2a18cd 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -394,6 +394,16 @@ int sql_set_variables(THD *thd, List *var_list, bool free); set_sys_var_value_origin(&VAR, sys_var::AUTO); \ } while(0) +#define SYSVAR_AUTOSIZE_IF_CHANGED(VAR,VAL,TYPE) \ + do { \ + TYPE tmp= (VAL); \ + if (VAR != tmp) \ + { \ + VAR= (VAL); \ + set_sys_var_value_origin(&VAR, sys_var::AUTO); \ + } \ + } while(0) + void set_sys_var_value_origin(void *ptr, enum sys_var::where here); enum sys_var::where get_sys_var_value_origin(void *ptr); @@ -416,6 +426,7 @@ CHARSET_INFO *get_old_charset_by_name(const char *old_name); int sys_var_init(); int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags); void sys_var_end(void); +bool check_has_super(sys_var *self, THD *thd, set_var *var); #endif diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 52be5e14e14224e34c4c81c23c67d3384033e63f..d73a22c80dc98799bd2c8d31e4481c592ab3abe4 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -5577,8 +5577,8 @@ ER_SP_NO_AGGREGATE 42000 eng "AGGREGATE is not supported for stored functions" ger "AGGREGATE wird bei gespeicherten Funktionen nicht unterstützt" ER_MAX_PREPARED_STMT_COUNT_REACHED 42000 - eng "Can't create more than max_prepared_stmt_count statements (current value: %lu)" - ger "Kann nicht mehr Anweisungen als max_prepared_stmt_count erzeugen (aktueller Wert: %lu)" + eng "Can't create more than max_prepared_stmt_count statements (current value: %u)" + ger "Kann nicht mehr Anweisungen als max_prepared_stmt_count erzeugen (aktueller Wert: %u)" ER_VIEW_RECURSIVE eng "`%-.192s`.`%-.192s` contains view recursion" ger "`%-.192s`.`%-.192s` enthält View-Rekursion" diff --git a/sql/slave.cc b/sql/slave.cc index da394ff711e932cb1b1121b7fb5f1623aa395158..6fe6de6872a3a34db054c64ee9e571c785324d5c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3898,10 +3898,10 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, DBUG_RETURN(1); #ifdef WITH_WSREP - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == NO_CONFLICT) { - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); #endif /* WITH_WSREP */ if (slave_trans_retries) { @@ -3978,7 +3978,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, #ifdef WITH_WSREP } else - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); #endif /* WITH_WSREP */ thread_safe_increment64(&rli->executed_entries); @@ -5128,7 +5128,7 @@ pthread_handler_t handle_slave_sql(void *arg) */ if (WSREP_ON && wsrep_node_dropped && wsrep_restart_slave) { - if (wsrep_ready) + if (wsrep_ready_get()) { WSREP_INFO("Slave error due to node temporarily non-primary" "SQL slave will continue"); diff --git a/sql/sp.cc b/sql/sp.cc index 2e268e483e74e77187b54d57bf1f03e23c0f4764..a5a14ec8d85b81aa2611120e18468f49c2a19757 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2002, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2002, 2018, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 @@ -347,7 +347,7 @@ class Proc_table_intact : public Table_check_intact bool m_print_once; public: - Proc_table_intact() : m_print_once(TRUE) {} + Proc_table_intact() : m_print_once(TRUE) { has_keys= TRUE; } protected: void report_error(uint code, const char *fmt, ...); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 8bf78d97670e6d6c56d31d4b8a3a18add6a88148..0d24ed04eaee9967c6843cf057d012e989ae7f32 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -840,7 +840,7 @@ sp_head::~sp_head() thd->lex->sphead= NULL; lex_end(thd->lex); delete thd->lex; - thd->lex= thd->stmt_lex= lex; + thd->lex= lex; } my_hash_free(&m_sptabs); @@ -1121,7 +1121,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success) backup_arena; query_id_t old_query_id; TABLE *old_derived_tables; - LEX *old_lex, *old_stmt_lex; + LEX *old_lex; Item_change_list old_change_list; String old_packet; uint old_server_status; @@ -1224,7 +1224,6 @@ sp_head::execute(THD *thd, bool merge_da_on_success) do it in each instruction */ old_lex= thd->lex; - old_stmt_lex= thd->stmt_lex; /* We should also save Item tree change list to avoid rollback something too early in the calling query. @@ -1372,7 +1371,6 @@ sp_head::execute(THD *thd, bool merge_da_on_success) DBUG_ASSERT(thd->change_list.is_empty()); old_change_list.move_elements_to(&thd->change_list); thd->lex= old_lex; - thd->stmt_lex= old_stmt_lex; thd->set_query_id(old_query_id); DBUG_ASSERT(!thd->derived_tables); thd->derived_tables= old_derived_tables; @@ -2207,7 +2205,7 @@ sp_head::reset_lex(THD *thd) if (sublex == 0) DBUG_RETURN(TRUE); - thd->lex= thd->stmt_lex= sublex; + thd->lex= sublex; (void)m_lex.push_front(oldlex); /* Reset most stuff. */ @@ -2953,7 +2951,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, We should not save old value since it is saved/restored in sp_head::execute() when we are entering/leaving routine. */ - thd->lex= thd->stmt_lex= m_lex; + thd->lex= m_lex; thd->set_query_id(next_query_id()); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 07b0715dc84a0c17ec1c924e75307842e6b086c1..a5c91b499517bfb674146bae0f783301a7b815e8 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2018, MariaDB 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 @@ -11475,6 +11475,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio, const char *client_auth_plugin= ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin; + DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); }); DBUG_ASSERT(client_auth_plugin); /* diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 98584ec4630aa2229f85a1388b8c9e00e7bd1c11..be23cd3341bf2137e4f0f169f0c9c0f10fb98330 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2010, 2015, Oracle and/or its affiliates. - Copyright (c) 2011, 2016, MariaDB + Copyright (c) 2011, 2018, MariaDB 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 @@ -238,7 +238,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, if (thd->locked_tables_list.locked_tables()) { - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) goto end; /* Restore the table in the table list with the new opened table */ table_list->table= pos_in_locked_tables->table; @@ -302,7 +302,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt, const char *operator_name, thr_lock_type lock_type, - bool open_for_modify, + bool org_open_for_modify, bool repair_table_use_frm, uint extra_open_options, int (*prepare_func)(THD *, TABLE_LIST *, @@ -365,10 +365,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, for (table= tables; table; table= table->next_local) { char table_name[SAFE_NAME_LEN*2+2]; - char* db = table->db; + char *db= table->db; bool fatal_error=0; bool open_error; bool collect_eis= FALSE; + bool open_for_modify= org_open_for_modify; DBUG_PRINT("admin", ("table: '%s'.'%s'", table->db, table->table_name)); strxmov(table_name, db, ".", table->table_name, NullS); @@ -406,8 +407,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, /* CHECK TABLE command is allowed for views as well. Check on alter flags - to differentiate from ALTER TABLE...CHECK PARTITION on which view is not - allowed. + to differentiate from ALTER TABLE...CHECK PARTITION on which view is + not allowed. */ if (lex->alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION || view_operator_func == NULL) @@ -1102,7 +1103,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, } } /* Error path, a admin command failed. */ - if (thd->transaction_rollback_request) + if (thd->transaction_rollback_request || fatal_error) { /* Unlikely, but transaction rollback was requested by one of storage @@ -1113,7 +1114,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, } else { - if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) + if (trans_commit_stmt(thd) || + (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END) && + trans_commit_implicit(thd))) goto err; } close_thread_tables(thd); @@ -1147,7 +1150,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, err: /* Make sure this table instance is not reused after the failure. */ trans_rollback_stmt(thd); - trans_rollback(thd); + if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END)) + trans_rollback(thd); if (table && table->table) { table->table->m_needs_reopen= true; diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index bff45e089a4b288592ebfd08d9804f8560112fc0..f17931ae919e3334f18352b256e00e33b381d3fe 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -262,8 +262,8 @@ bool Sql_cmd_alter_table::execute(THD *thd) - For temporary MERGE tables we do not track if their child tables are base or temporary. As result we can't guarantee that privilege check - which was done in presence of temporary child will stay relevant later - as this temporary table might be removed. + which was done in presence of temporary child will stay relevant + later as this temporary table might be removed. If SELECT_ACL | UPDATE_ACL | DELETE_ACL privileges were not checked for the underlying *base* tables, it would create a security breach as in diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc index 098e99e88fcb031b4378ab4a81aae68c94ee0520..68299d024fdb0c8332cc0af62610d26f5eeff96e 100644 --- a/sql/sql_analyze_stmt.cc +++ b/sql/sql_analyze_stmt.cc @@ -39,7 +39,7 @@ void Filesort_tracker::print_json_members(Json_writer *writer) if (r_limit == 0) writer->add_str(varied_str); else - writer->add_ll((longlong) rint(r_limit/get_r_loops())); + writer->add_ll((longlong) rint(r_limit)); } writer->add_member("r_used_priority_queue"); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 01f40bb22470e7d08cf6ba273d966ccd951a95e4..c2bf37a10649b1088f8075b43d0fd2e8618b321f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -592,7 +592,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, old locks. This should always succeed (unless some external process has removed the tables) */ - thd->locked_tables_list.reopen_tables(thd); + thd->locked_tables_list.reopen_tables(thd, false); /* Since downgrade_lock() won't do anything with shared metadata lock it is much simpler to go through all open tables rather @@ -1322,7 +1322,8 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, @param thd thread handle @param table table which should be checked @param table_list list of tables - @param check_alias whether to check tables' aliases + @param check_flag whether to check tables' aliases + Currently this is only used by INSERT NOTE: to exclude derived tables from check we use following mechanism: a) during derived table processing set THD::derived_tables_processing @@ -1351,9 +1352,9 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, static TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, - bool check_alias) + uint check_flag) { - TABLE_LIST *res; + TABLE_LIST *res= 0; const char *d_name, *t_name, *t_alias; DBUG_ENTER("find_dup_table"); DBUG_PRINT("enter", ("table alias: %s", table->alias)); @@ -1389,17 +1390,15 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, retry: DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); - for (TABLE_LIST *tl= table_list;;) + for (TABLE_LIST *tl= table_list; tl ; tl= tl->next_global, res= 0) { - if (tl && - tl->select_lex && tl->select_lex->master_unit() && + if (tl->select_lex && tl->select_lex->master_unit() && tl->select_lex->master_unit()->executed) { /* There is no sense to check tables of already executed parts of the query */ - tl= tl->next_global; continue; } /* @@ -1408,21 +1407,29 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, */ if (! (res= find_table_in_global_list(tl, d_name, t_name))) break; + tl= res; // We can continue search after this table /* Skip if same underlying table. */ if (res->table && (res->table == table->table)) - goto next; + continue; + + if (check_flag & CHECK_DUP_FOR_CREATE) + DBUG_RETURN(res); /* Skip if table alias does not match. */ - if (check_alias) + if (check_flag & CHECK_DUP_ALLOW_DIFFERENT_ALIAS) { if (my_strcasecmp(table_alias_charset, t_alias, res->alias)) - goto next; + continue; } /* - Skip if marked to be excluded (could be a derived table) or if - entry is a prelocking placeholder. + If table is not excluded (could be a derived table) and table is not + a prelocking placeholder then we found either a duplicate entry + or a table that is part of a derived table (handled below). + Examples are: + INSERT INTO t1 SELECT * FROM t1; + INSERT INTO t1 SELECT * FROM view_containing_t1; */ if (res->select_lex && !res->select_lex->exclude_from_table_unique_test && @@ -1434,14 +1441,17 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, processed in derived table or top select of multi-update/multi-delete (exclude_from_table_unique_test) or prelocking placeholder. */ -next: - tl= res->next_global; DBUG_PRINT("info", ("found same copy of table or table which we should skip")); } if (res && res->belong_to_derived) { - /* Try to fix */ + /* + We come here for queries of type: + INSERT INTO t1 (SELECT tmp.a FROM (select * FROM t1) as tmp); + + Try to fix by materializing the derived table + */ TABLE_LIST *derived= res->belong_to_derived; if (derived->is_merged_derived()) { @@ -1473,7 +1483,7 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, - bool check_alias) + uint check_flag) { TABLE_LIST *dup; @@ -1487,12 +1497,12 @@ unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, for (child= table->next_global; child && child->parent_l == table; child= child->next_global) { - if ((dup= find_dup_table(thd, child, child->next_global, check_alias))) + if ((dup= find_dup_table(thd, child, child->next_global, check_flag))) break; } } else - dup= find_dup_table(thd, table, table_list, check_alias); + dup= find_dup_table(thd, table, table_list, check_flag); return dup; } /* @@ -2911,7 +2921,8 @@ void Locked_tables_list::unlink_from_list(THD *thd, If mode is not LTM_LOCK_TABLES, we needn't do anything. Moreover, outside this mode pos_in_locked_tables value is not trustworthy. */ - if (thd->locked_tables_mode != LTM_LOCK_TABLES) + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) return; /* @@ -3015,7 +3026,7 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count) */ bool -Locked_tables_list::reopen_tables(THD *thd) +Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) { Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); size_t reopen_count= 0; @@ -3026,8 +3037,20 @@ Locked_tables_list::reopen_tables(THD *thd) for (TABLE_LIST *table_list= m_locked_tables; table_list; table_list= table_list->next_global) { - if (table_list->table) /* The table was not closed */ - continue; + if (need_reopen) + { + if (!table_list->table || !table_list->table->needs_reopen()) + continue; + /* no need to remove the table from the TDC here, thus (TABLE*)1 */ + close_all_tables_for_name(thd, table_list->table->s, + HA_EXTRA_NOT_USED, (TABLE*)1); + DBUG_ASSERT(table_list->table == NULL); + } + else + { + if (table_list->table) /* The table was not closed */ + continue; + } /* Links into thd->open_tables upon success */ if (open_table(thd, table_list, &ot_ctx)) @@ -6184,6 +6207,9 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, column reference. See create_view_field() for details. */ item= nj_col->create_item(thd); + if (!item) + DBUG_RETURN(NULL); + /* *ref != NULL means that *ref contains the item that we need to replace. If the item was aliased by the user, set the alias to diff --git a/sql/sql_base.h b/sql/sql_base.h index c73ea3745071969d4ad593a8f1b9d5f9754abd77..74154184ebcb3e8f5a492c41f93c4854110748e5 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -1,4 +1,6 @@ /* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2011, 2018, MariaDB + 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 @@ -59,6 +61,10 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND, IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE, IGNORE_EXCEPT_NON_UNIQUE}; +/* Flag bits for unique_table() */ +#define CHECK_DUP_ALLOW_DIFFERENT_ALIAS 1 +#define CHECK_DUP_FOR_CREATE 2 + uint create_tmp_table_def_key(THD *thd, char *key, const char *db, const char *table_name); uint get_table_def_key(const TABLE_LIST *table_list, const char **key); @@ -278,7 +284,7 @@ void kill_delayed_threads_for_table(TDC_element *element); void close_thread_table(THD *thd, TABLE **table_ptr); bool close_temporary_tables(THD *thd); TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, - bool check_alias); + uint check_flag); int drop_temporary_table(THD *thd, TABLE *table, bool *is_trans); void close_temporary_table(THD *thd, TABLE *table, bool free_share, bool delete_table); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e3b7b31b01d411bbdc82e09ad34b2cd30dd12fe3..0a95d2e2cc59b090172b2906da69e6ef41a76ee1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -683,103 +683,6 @@ extern "C" } -/** - Dumps a text description of a thread, its security context - (user, host) and the current query. - - @param thd thread context - @param buffer pointer to preferred result buffer - @param length length of buffer - @param max_query_len how many chars of query to copy (0 for all) - - @return Pointer to string -*/ - -extern "C" -char *thd_get_error_context_description(THD *thd, char *buffer, - unsigned int length, - unsigned int max_query_len) -{ - String str(buffer, length, &my_charset_latin1); - const Security_context *sctx= &thd->main_security_ctx; - char header[256]; - int len; - - mysql_mutex_lock(&LOCK_thread_count); - - /* - The pointers thd->query and thd->proc_info might change since they are - being modified concurrently. This is acceptable for proc_info since its - values doesn't have to very accurate and the memory it points to is static, - but we need to attempt a snapshot on the pointer values to avoid using NULL - values. The pointer to thd->query however, doesn't point to static memory - and has to be protected by thd->LOCK_thd_data or risk pointing to - uninitialized memory. - */ - const char *proc_info= thd->proc_info; - - len= my_snprintf(header, sizeof(header), - "MySQL thread id %lu, OS thread handle 0x%lx, query id %lu", - thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id); - str.length(0); - str.append(header, len); - - if (sctx->host) - { - str.append(' '); - str.append(sctx->host); - } - - if (sctx->ip) - { - str.append(' '); - str.append(sctx->ip); - } - - if (sctx->user) - { - str.append(' '); - str.append(sctx->user); - } - - if (proc_info) - { - str.append(' '); - str.append(proc_info); - } - - /* Don't wait if LOCK_thd_data is used as this could cause a deadlock */ - if (!mysql_mutex_trylock(&thd->LOCK_thd_data)) - { - if (thd->query()) - { - if (max_query_len < 1) - len= thd->query_length(); - else - len= MY_MIN(thd->query_length(), max_query_len); - str.append('\n'); - str.append(thd->query(), len); - } - mysql_mutex_unlock(&thd->LOCK_thd_data); - } - mysql_mutex_unlock(&LOCK_thread_count); - - if (str.c_ptr_safe() == buffer) - return buffer; - - /* - We have to copy the new string to the destination buffer because the string - was reallocated to a larger buffer to be able to fit. - */ - DBUG_ASSERT(buffer != NULL); - length= MY_MIN(str.length(), length-1); - memcpy(buffer, str.c_ptr_quick(), length); - /* Make sure that the new string is null terminated */ - buffer[length]= '\0'; - return buffer; -} - - #if MARIA_PLUGIN_INTERFACE_VERSION < 0x0200 /** TODO: This function is for API compatibility, remove it eventually. @@ -1008,7 +911,6 @@ THD::THD(bool is_wsrep_applier) *scramble= '\0'; #ifdef WITH_WSREP - mysql_mutex_init(key_LOCK_wsrep_thd, &LOCK_wsrep_thd, MY_MUTEX_INIT_FAST); wsrep_ws_handle.trx_id = WSREP_UNDEFINED_TRX_ID; wsrep_ws_handle.opaque = NULL; wsrep_retry_counter = 0; @@ -1644,9 +1546,6 @@ THD::~THD() mysql_mutex_unlock(&LOCK_thd_data); #ifdef WITH_WSREP - mysql_mutex_lock(&LOCK_wsrep_thd); - mysql_mutex_unlock(&LOCK_wsrep_thd); - mysql_mutex_destroy(&LOCK_wsrep_thd); if (wsrep_rgi) delete wsrep_rgi; #endif /* Close connection */ @@ -2717,15 +2616,19 @@ void THD::check_and_register_item_tree_change(Item **place, Item **new_value, void THD::rollback_item_tree_changes() { + DBUG_ENTER("THD::rollback_item_tree_changes"); I_List_iterator it(change_list); Item_change_record *change; while ((change= it++)) { + DBUG_PRINT("info", ("Rollback: %p (%p) <- %p", + *change->place, change->place, change->old_value)); *change->place= change->old_value; } /* We can forget about changes memory: it's allocated in runtime memroot */ change_list.empty(); + DBUG_VOID_RETURN; } @@ -3654,7 +3557,7 @@ void Statement::set_statement(Statement *stmt) { id= stmt->id; mark_used_columns= stmt->mark_used_columns; - stmt_lex= lex= stmt->lex; + lex= stmt->lex; query_string= stmt->query_string; } @@ -7100,6 +7003,13 @@ bool THD::rgi_have_temporary_tables() return rgi_slave->rli->save_temporary_tables != 0; } +bool THD::is_optimistic_slave_worker() +{ + DBUG_ASSERT(system_thread != SYSTEM_THREAD_SLAVE_SQL || rgi_slave); + + return system_thread == SYSTEM_THREAD_SLAVE_SQL && rgi_slave && + rgi_slave->speculation == rpl_group_info::SPECULATE_OPTIMISTIC; +} void wait_for_commit::reinit() diff --git a/sql/sql_class.h b/sql/sql_class.h index 91030145022fdef1c891886ca1fd6b2b86c738c3..fb3604b899b28e8e56d94363ee4216aad6d0d1d6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1027,21 +1027,6 @@ class Statement: public ilink, public Query_arena LEX_STRING name; /* name for named prepared statements */ LEX *lex; // parse tree descriptor - /* - LEX which represents current statement (conventional, SP or PS) - - For example during view parsing THD::lex will point to the views LEX and - THD::stmt_lex will point to LEX of the statement where the view will be - included - - Currently it is used to have always correct select numbering inside - statement (LEX::current_select_number) without storing and restoring a - global counter which was THD::select_number. - - TODO: make some unified statement representation (now SP has different) - to store such data like LEX::current_select_number. - */ - LEX *stmt_lex; /* Points to the query associated with this statement. It's const, but we need to declare it char * because all table handlers are written @@ -1697,7 +1682,7 @@ class Locked_tables_list void unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count); - bool reopen_tables(THD *thd); + bool reopen_tables(THD *thd, bool need_reopen); bool restore_lock(THD *thd, TABLE_LIST *dst_table_list, TABLE *table, MYSQL_LOCK *lock); void add_back_last_deleted_lock(TABLE_LIST *dst_table_list); @@ -2955,6 +2940,7 @@ class THD :public Statement, query_id_t first_query_id; } binlog_evt_union; + mysql_cond_t COND_wsrep_thd; /** Internal parser state. Note that since the parser is not re-entrant, we keep only one parser @@ -4105,7 +4091,6 @@ class THD :public Statement, query_id_t wsrep_last_query_id; enum wsrep_query_state wsrep_query_state; enum wsrep_conflict_state wsrep_conflict_state; - mysql_mutex_t LOCK_wsrep_thd; wsrep_trx_meta_t wsrep_trx_meta; uint32 wsrep_rand; Relay_log_info *wsrep_rli; @@ -4183,6 +4168,12 @@ class THD :public Statement, (THD_TRANS::DID_WAIT | THD_TRANS::CREATED_TEMP_TABLE | THD_TRANS::DROPPED_TEMP_TABLE | THD_TRANS::DID_DDL)); } + + /* + Returns true when the thread handle belongs to a slave worker thread + running in the optimistic execution mode. + */ + bool is_optimistic_slave_worker(); }; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index d3ef245209d924680686cd1fbca639157b5e5407..abb234ab4b1f0d5b7f394cf828ccd21251a05dde 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1335,9 +1335,9 @@ void do_handle_one_connection(THD *thd_arg) #ifdef WITH_WSREP if (WSREP(thd)) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_query_state= QUERY_EXITING; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif end_thread: diff --git a/sql/sql_const.h b/sql/sql_const.h index 946cf13e2ae95c34db04d5dd5b1262f9abf84a4c..0cd214d8bc7d43cbdd04f651a1dab7e430cd85a4 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -124,7 +124,7 @@ #define MAX_ACCEPT_RETRY 10 // Test accept this many times #define MAX_FIELDS_BEFORE_HASH 32 #define USER_VARS_HASH_SIZE 16 -#define TABLE_OPEN_CACHE_MIN 400 +#define TABLE_OPEN_CACHE_MIN 200 #define TABLE_OPEN_CACHE_DEFAULT 2000 #define TABLE_DEF_CACHE_DEFAULT 400 /** diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index bc067b667a69b5718c0991cf863fbb5d265be2f3..453d7ffdc0157ebbc75258d351d1227e0a2159f4 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -945,7 +945,7 @@ multi_delete::initialize_tables(JOIN *join) TABLE_LIST *tbl= walk->correspondent_table->find_table_for_update(); tables_to_delete_from|= tbl->table->map; if (delete_while_scanning && - unique_table(thd, tbl, join->tables_list, false)) + unique_table(thd, tbl, join->tables_list, 0)) { /* If the table we are going to delete from appears diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index ac6bee050014fdcb7876d5616be8159f1b89dc0d..82107f9b922d752a17d2765e35f5a58dbffac374 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1642,7 +1642,7 @@ void Explain_table_access::print_explain_json(Explain_query *query, { /* Get r_filtered value from filesort */ if (fs_tracker->get_r_loops()) - writer->add_double(fs_tracker->get_r_filtered()); + writer->add_double(fs_tracker->get_r_filtered()*100); else writer->add_null(); } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 662fa33dc9f5e3a2c3804115cfd1021b51941e1c..5a022ba72cfa4342db4cda9791ecfaff2748ccd0 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -155,10 +155,11 @@ static void mysql_ha_close_table(SQL_HANDLER *handler) { THD *thd= handler->thd; TABLE *table= handler->table; + DBUG_ENTER("mysql_ha_close_table"); /* check if table was already closed */ if (!table) - return; + DBUG_VOID_RETURN; if (!table->s->tmp_table) { @@ -184,6 +185,7 @@ static void mysql_ha_close_table(SQL_HANDLER *handler) } my_free(handler->lock); handler->init(); + DBUG_VOID_RETURN; } /* @@ -985,6 +987,7 @@ SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables, if (!(handler= mysql_ha_find_handler(thd, tables->alias))) DBUG_RETURN(0); tables->table= handler->table; // This is used by fix_fields + handler->table->pos_in_table_list= tables; if (mysql_ha_fix_cond_and_key(handler, mode, keyname, key_expr, cond, 1)) DBUG_RETURN(0); DBUG_RETURN(handler); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0a9ce00c95089f6cbc692f56663e6475c6bb6baa..e103c3b390cf894e37cea81cebfbef3782717a02 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1550,7 +1550,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, { Item *fake_conds= 0; TABLE_LIST *duplicate; - if ((duplicate= unique_table(thd, table_list, table_list->next_global, 1))) + if ((duplicate= unique_table(thd, table_list, table_list->next_global, + CHECK_DUP_ALLOW_DIFFERENT_ALIAS))) { update_non_unique_table_error(table_list, "INSERT", duplicate); DBUG_RETURN(TRUE); @@ -4382,22 +4383,54 @@ bool select_create::send_eof() */ if (!table->s->tmp_table) { +#ifdef WITH_WSREP + if (WSREP_ON) + { + /* + append table level exclusive key for CTAS + */ + wsrep_key_arr_t key_arr= {0, 0}; + wsrep_prepare_keys_for_isolation(thd, + create_table->db, + create_table->table_name, + table_list, + &key_arr); + int rcode = wsrep->append_key( + wsrep, + &thd->wsrep_ws_handle, + key_arr.keys, //&wkey, + key_arr.keys_len, + WSREP_KEY_EXCLUSIVE, + false); + wsrep_keys_free(&key_arr); + if (rcode) { + DBUG_PRINT("wsrep", ("row key failed: %d", rcode)); + WSREP_ERROR("Appending table key for CTAS failed: %s, %d", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void", rcode); + return true; + } + /* If commit fails, we should be able to reset the OK status. */ + thd->get_stmt_da()->set_overwrite_status(TRUE); + } +#endif /* WITH_WSREP */ trans_commit_stmt(thd); if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) trans_commit_implicit(thd); #ifdef WITH_WSREP if (WSREP_ON) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + thd->get_stmt_da()->set_overwrite_status(FALSE); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state != NO_CONFLICT) { WSREP_DEBUG("select_create commit failed, thd: %lu err: %d %s", thd->thread_id, thd->wsrep_conflict_state, thd->query()); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); abort_result_set(); DBUG_RETURN(true); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3fa5ec71aeb67d65c76ec8027582434c451e3738..085ad1a4b3bbb14bd44d88e7ba702e58a57a5b88 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -657,10 +657,11 @@ void lex_start(THD *thd) { LEX *lex= thd->lex; DBUG_ENTER("lex_start"); - DBUG_PRINT("info", ("Lex %p stmt_lex: %p", thd->lex, thd->stmt_lex)); + DBUG_PRINT("info", ("Lex %p", thd->lex)); lex->thd= lex->unit.thd= thd; - + + lex->stmt_lex= lex; // default, should be rewritten for VIEWs And CTEs DBUG_ASSERT(!lex->explain); lex->context_stack.empty(); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 4fcd090e1f5bd98fb324c16ea48dbe56392f87f9..3b47b1d25c98524660dc156f2c32a94e87282cd0 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -730,7 +730,7 @@ class st_select_lex: public st_select_lex_node /* Point to the LEX in which it was created, used in view subquery detection. - TODO: make also st_select_lex::parent_stmt_lex (see THD::stmt_lex) + TODO: make also st_select_lex::parent_stmt_lex (see LEX::stmt_lex) and use st_select_lex::parent_lex & st_select_lex::parent_stmt_lex instead of global (from THD) references where it is possible. */ @@ -2435,6 +2435,21 @@ struct LEX: public Query_tables_list // type information char *length,*dec; CHARSET_INFO *charset; + /* + LEX which represents current statement (conventional, SP or PS) + + For example during view parsing THD::lex will point to the views LEX and + lex::stmt_lex will point to LEX of the statement where the view will be + included + + Currently it is used to have always correct select numbering inside + statement (LEX::current_select_number) without storing and restoring a + global counter which was THD::select_number. + + TODO: make some unified statement representation (now SP has different) + to store such data like LEX::current_select_number. + */ + LEX *stmt_lex; LEX_STRING name; char *help_arg; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4dd8d9e124ee0d42b705aff7681ecf302659fbe6..89b5adff60ce78436f7f500ba236e638d0d4e9e0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB + Copyright (c) 2008, 2018, MariaDB 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 @@ -198,7 +198,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) /* - Implicitly commit a active transaction if statement requires so. + Check whether the statement implicitly commits an active transaction. @param thd Thread handle. @param mask Bitmask used for the SQL command match. @@ -206,7 +206,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) @return 0 No implicit commit @return 1 Do a commit */ -static bool stmt_causes_implicit_commit(THD *thd, uint mask) +bool stmt_causes_implicit_commit(THD *thd, uint mask) { LEX *lex= thd->lex; bool skip= FALSE; @@ -275,6 +275,7 @@ void init_update_queries(void) server_command_flags[COM_SHUTDOWN]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_SLEEP]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_TIME]= CF_SKIP_WSREP_CHECK; + server_command_flags[COM_INIT_DB]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK; /* @@ -284,6 +285,8 @@ void init_update_queries(void) server_command_flags[COM_QUERY]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_SET_OPTION]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK; + server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK; + server_command_flags[COM_STMT_FETCH]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_STMT_CLOSE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK; server_command_flags[COM_STMT_RESET]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK; server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK; @@ -517,6 +520,8 @@ void init_update_queries(void) There are other statements that deal with temporary tables and open them, but which are not listed here. The thing is that the order of pre-opening temporary tables for those statements is somewhat custom. + + Note that SQLCOM_RENAME_TABLE should not be in this list! */ sql_command_flags[SQLCOM_CREATE_TABLE]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_DROP_TABLE]|= CF_PREOPEN_TMP_TABLES; @@ -530,7 +535,6 @@ void init_update_queries(void) sql_command_flags[SQLCOM_INSERT_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_DELETE]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_DELETE_MULTI]|= CF_PREOPEN_TMP_TABLES; - sql_command_flags[SQLCOM_RENAME_TABLE]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_REPLACE_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_SELECT]|= CF_PREOPEN_TMP_TABLES; sql_command_flags[SQLCOM_SET_OPTION]|= CF_PREOPEN_TMP_TABLES; @@ -887,21 +891,26 @@ void cleanup_items(Item *item) } -#ifndef EMBEDDED_LIBRARY - #ifdef WITH_WSREP -static bool wsrep_node_is_ready(THD *thd) +static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) { - if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready) + for (const TABLE_LIST *table= tables; table; table= table->next_global) { - my_message(ER_UNKNOWN_COM_ERROR, - "WSREP has not yet prepared node for application use", - MYF(0)); - return false; + TABLE_CATEGORY c; + LEX_STRING db, tn; + lex_string_set(&db, table->db); + lex_string_set(&tn, table->table_name); + c= get_table_category(&db, &tn); + if (c != TABLE_CATEGORY_INFORMATION && + c != TABLE_CATEGORY_PERFORMANCE) + { + return false; + } } return true; } -#endif +#endif /* WITH_WSREP */ +#ifndef EMBEDDED_LIBRARY /** Read one command from connection and execute it (query or simple command). @@ -931,13 +940,13 @@ bool do_command(THD *thd) #ifdef WITH_WSREP if (WSREP(thd)) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_query_state= QUERY_IDLE; if (thd->wsrep_conflict_state==MUST_ABORT) { wsrep_client_rollback(thd); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -983,15 +992,15 @@ bool do_command(THD *thd) packet_length= my_net_read_packet(net, 1); #ifdef WITH_WSREP if (WSREP(thd)) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); /* these THD's are aborted or are aborting during being idle */ if (thd->wsrep_conflict_state == ABORTING) { while (thd->wsrep_conflict_state == ABORTING) { - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); my_sleep(1000); - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); } thd->store_globals(); } @@ -1001,7 +1010,7 @@ bool do_command(THD *thd) } thd->wsrep_query_state= QUERY_EXEC; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -1014,13 +1023,13 @@ bool do_command(THD *thd) #ifdef WITH_WSREP if (WSREP(thd)) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == MUST_ABORT) { DBUG_PRINT("wsrep",("aborted for wsrep rollback: %lu", thd->real_id)); wsrep_client_rollback(thd); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -1080,21 +1089,27 @@ bool do_command(THD *thd) command_name[command].str)); #ifdef WITH_WSREP - /* - Bail out if DB snapshot has not been installed. - */ - if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) && - !wsrep_node_is_ready(thd)) + if (WSREP(thd)) { - thd->protocol->end_statement(); + /* + Bail out if DB snapshot has not been installed. + */ + if (!thd->wsrep_applier && + (!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) && + (server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0) + { + my_message(ER_UNKNOWN_COM_ERROR, + "WSREP has not yet prepared node for application use", MYF(0)); + thd->protocol->end_statement(); - /* Performance Schema Interface instrumentation end. */ - MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da()); - thd->m_statement_psi= NULL; - thd->m_digest= NULL; + /* Performance Schema Interface instrumentation end. */ + MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da()); + thd->m_statement_psi= NULL; + thd->m_digest= NULL; - return_value= FALSE; - goto out; + return_value= FALSE; + goto out; + } } #endif @@ -1242,7 +1257,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->wsrep_PA_safe= true; } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_query_state= QUERY_EXEC; if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT) { @@ -1258,14 +1273,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction"); WSREP_DEBUG("Deadlock error for: %s", thd->query()); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); thd->reset_killed(); thd->mysys_var->abort = 0; thd->wsrep_conflict_state = NO_CONFLICT; thd->wsrep_retry_counter = 0; goto dispatch_end; } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ #if defined(ENABLED_PROFILING) @@ -1920,10 +1935,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, DBUG_ASSERT((command != COM_QUIT && command != COM_STMT_CLOSE) || thd->get_stmt_da()->is_disabled()); /* wsrep BF abort in query exec phase */ - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); do_end_of_statement= thd->wsrep_conflict_state != REPLAYING && thd->wsrep_conflict_state != RETRY_AUTOCOMMIT; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } else do_end_of_statement= true; @@ -2460,10 +2475,6 @@ mysql_execute_command(THD *thd) #endif DBUG_ENTER("mysql_execute_command"); -#ifdef WITH_PARTITION_STORAGE_ENGINE - thd->work_part_info= 0; -#endif - DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt); /* Each statement or replication event which might produce deadlock @@ -2653,20 +2664,22 @@ mysql_execute_command(THD *thd) } /* - Bail out if DB snapshot has not been installed. SET and SHOW commands, - however, are always allowed. - Select query is also allowed if it does not access any table. - We additionally allow all other commands that do not change data in - case wsrep_dirty_reads is enabled. - */ - if (lex->sql_command != SQLCOM_SET_OPTION && - !wsrep_is_show_query(lex->sql_command) && - !(thd->variables.wsrep_dirty_reads && - !is_update_query(lex->sql_command)) && - !(lex->sql_command == SQLCOM_SELECT && - !all_tables) && - !wsrep_node_is_ready(thd)) + * Bail out if DB snapshot has not been installed. We however, + * allow SET and SHOW queries and reads from information schema + * and dirty reads (if configured) + */ + if (!thd->wsrep_applier && + !(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) && + !(thd->variables.wsrep_dirty_reads && + (sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) && + !wsrep_tables_accessible_when_detached(all_tables) && + lex->sql_command != SQLCOM_SET_OPTION && + !wsrep_is_show_query(lex->sql_command)) + { + my_message(ER_UNKNOWN_COM_ERROR, + "WSREP has not yet prepared node for application use", MYF(0)); goto error; + } } #endif /* WITH_WSREP */ status_var_increment(thd->status_var.com_stat[lex->sql_command]); @@ -2902,6 +2915,7 @@ mysql_execute_command(THD *thd) { WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); execute_show_status(thd, all_tables); + break; } case SQLCOM_SHOW_EXPLAIN: @@ -3401,7 +3415,7 @@ mysql_execute_command(THD *thd) TABLE_LIST *duplicate; if ((duplicate= unique_table(thd, lex->query_tables, lex->query_tables->next_global, - 0))) + CHECK_DUP_FOR_CREATE))) { update_non_unique_table_error(lex->query_tables, "CREATE", duplicate); @@ -3947,7 +3961,7 @@ mysql_execute_command(THD *thd) case SQLCOM_INSERT_SELECT: { WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); - select_result *sel_result; + select_insert *sel_result; bool explain= MY_TEST(lex->describe); DBUG_ASSERT(first_table == all_tables && first_table != 0); if (WSREP_CLIENT(thd) && @@ -5706,6 +5720,10 @@ mysql_execute_command(THD *thd) lex->unit.cleanup(); + /* close/reopen tables that were marked to need reopen under LOCK TABLES */ + if (! thd->lex->requires_prelocking()) + thd->locked_tables_list.reopen_tables(thd, true); + if (! thd->in_sub_stmt) { if (thd->killed != NOT_KILLED) @@ -5975,6 +5993,60 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables) } +/* + Find out if a table is a temporary table + + A table is a temporary table if it's a temporary table or + there has been before a temporary table that has been renamed + to the current name. + + Some examples: + A->B B is a temporary table if and only if A is a temp. + A->B, B->C Second B is temp if A is temp + A->B, A->C Second A can't be temp as if A was temp then B is temp + and Second A can only be a normal table. C is also not temp +*/ + +static TABLE *find_temporary_table_for_rename(THD *thd, + TABLE_LIST *first_table, + TABLE_LIST *cur_table) +{ + TABLE_LIST *table; + TABLE *res= 0; + bool found= 0; + DBUG_ENTER("find_temporary_table_for_rename"); + + /* Find last instance when cur_table is in TO part */ + for (table= first_table; + table != cur_table; + table= table->next_local->next_local) + { + TABLE_LIST *next= table->next_local; + + if (!strcmp(table->get_db_name(), cur_table->get_db_name()) && + !strcmp(table->get_table_name(), cur_table->get_table_name())) + { + /* Table was moved away, can't be same as 'table' */ + found= 1; + res= 0; // Table can't be a temporary table + } + if (!strcmp(next->get_db_name(), cur_table->get_db_name()) && + !strcmp(next->get_table_name(), cur_table->get_table_name())) + { + /* + Table has matching name with new name of this table. cur_table should + have same temporary type as this table. + */ + found= 1; + res= table->table; + } + } + if (!found) + res= find_temporary_table(thd, table); + DBUG_RETURN(res); +} + + static bool check_rename_table(THD *thd, TABLE_LIST *first_table, TABLE_LIST *all_tables) { @@ -5991,13 +6063,19 @@ static bool check_rename_table(THD *thd, TABLE_LIST *first_table, &table->next_local->grant.m_internal, 0, 0)) return 1; + + /* check if these are refering to temporary tables */ + table->table= find_temporary_table_for_rename(thd, first_table, table); + table->next_local->table= table->table; + TABLE_LIST old_list, new_list; /* we do not need initialize old_list and new_list because we will - come table[0] and table->next[0] there + copy table[0] and table->next[0] there */ old_list= table[0]; new_list= table->next_local[0]; + if (check_grant(thd, ALTER_ACL | DROP_ACL, &old_list, FALSE, 1, FALSE) || (!test_all_bits(table->next_local->grant.privilege, INSERT_ACL | CREATE_ACL) && @@ -6907,8 +6985,9 @@ void THD::reset_for_next_command(bool do_clear_error) We also assign thd->stmt_lex in lex_start(), but during bootstrap this code is executed first. */ - thd->stmt_lex= &main_lex; thd->stmt_lex->current_select_number= 1; - DBUG_PRINT("info", ("Lex %p stmt_lex: %p", thd->lex, thd->stmt_lex)); + DBUG_ASSERT(lex == &main_lex); + main_lex.stmt_lex= &main_lex; main_lex.current_select_number= 1; + DBUG_PRINT("info", ("Lex and stmt_lex: %p", &main_lex)); /* Those two lines below are theoretically unneeded as THD::cleanup_after_query() should take care of this already. @@ -7026,7 +7105,7 @@ mysql_new_select(LEX *lex, bool move_down) if (!(select_lex= new (thd->mem_root) SELECT_LEX())) DBUG_RETURN(1); - select_lex->select_number= ++thd->stmt_lex->current_select_number; + select_lex->select_number= ++thd->lex->stmt_lex->current_select_number; select_lex->parent_lex= lex; /* Used in init_query. */ select_lex->init_query(); select_lex->init_select(); @@ -7171,12 +7250,21 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, com_statement_info[thd->get_command()].m_key); MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(), thd->query_length()); + + DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit", + { + const char act[]= + "now " + "SIGNAL wsrep_retry_autocommit_reached " + "WAIT_FOR wsrep_retry_autocommit_continue"; + DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); + }); } mysql_parse(thd, rawbuf, length, parser_state); if (WSREP(thd)) { /* wsrep BF abort in query exec phase */ - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == MUST_ABORT) { wsrep_client_rollback(thd); @@ -7185,6 +7273,11 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, if (thd->wsrep_conflict_state == MUST_REPLAY) { + mysql_mutex_unlock(&thd->LOCK_thd_data); + if (thd->lex->explain) + delete_explain_query(thd->lex); + mysql_mutex_lock(&thd->LOCK_thd_data); + wsrep_replay_transaction(thd); } @@ -7193,7 +7286,6 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, thd->wsrep_conflict_state == CERT_FAILURE) { thd->reset_for_next_command(); - thd->reset_killed(); if (is_autocommit && thd->lex->sql_command != SQLCOM_SELECT && (thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit)) @@ -7221,22 +7313,27 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, thd->thread_id, is_autocommit, thd->wsrep_retry_counter, thd->variables.wsrep_retry_autocommit, thd->query()); my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction"); - thd->reset_killed(); thd->wsrep_conflict_state= NO_CONFLICT; if (thd->wsrep_conflict_state != REPLAYING) thd->wsrep_retry_counter= 0; // reset } + mysql_mutex_unlock(&thd->LOCK_thd_data); + thd->reset_killed(); } else { set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok + mysql_mutex_unlock(&thd->LOCK_thd_data); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); } /* If retry is requested clean up explain structure */ - if (thd->wsrep_conflict_state == RETRY_AUTOCOMMIT && thd->lex->explain) + if ((thd->wsrep_conflict_state == RETRY_AUTOCOMMIT || + thd->wsrep_conflict_state == MUST_REPLAY ) + && thd->lex->explain) + { delete_explain_query(thd->lex); + } } while (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT); @@ -8185,7 +8282,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ if (((thd->security_ctx->master_access & SUPER_ACL) || thd->security_ctx->user_matches(tmp->security_ctx)) && - !wsrep_thd_is_BF(tmp, true)) + !wsrep_thd_is_BF(tmp, false)) { tmp->awake(kill_signal); error=0; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index da9721df0b707665ed0efe0371008a4ac1c43501..602a3e8d788067e7affb043deacd2d4cdd9ab409 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -85,6 +85,7 @@ bool check_identifier_name(LEX_STRING *str, uint max_char_length, uint err_code, const char *param_for_err_msg); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); bool sqlcom_can_generate_row_events(const THD *thd); +bool stmt_causes_implicit_commit(THD *thd, uint mask); bool is_update_query(enum enum_sql_command command); bool is_log_table_write_query(enum enum_sql_command command); bool alloc_query(THD *thd, const char *packet, uint packet_length); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 13e5f16685c7433cf2f7ce6d659c2344204cc5e2..65c76127de9e02ed350c1f369d551559f66ea8a2 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, SkySQL Ab. + Copyright (c) 2009, 2018, MariaDB 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 @@ -6555,7 +6555,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) thd->set_stmt_da(&tmp_stmt_da); } - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE"); if (stmt_da) @@ -6759,7 +6759,7 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, thd->set_stmt_da(&tmp_stmt_da); } - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE"); if (stmt_da) diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index e850677f8d947d1932ca29f99cca153b17e6b66b..1ac9e748d4215070b584b372ba9e20d6f4db4e1b 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -652,7 +652,7 @@ bool Sql_cmd_alter_table_exchange_partition:: better to keep master/slave in consistent state. Alternative would be to try to revert the exchange operation and issue error. */ - (void) thd->locked_tables_list.reopen_tables(thd); + (void) thd->locked_tables_list.reopen_tables(thd, false); if ((error= write_bin_log(thd, TRUE, thd->query(), thd->query_length()))) { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index d57137b30f65e3555d15885c925317d2aa080d45..7e4be9aed167c867ca34dffdceeff5b7eb58c521 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2005, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB Corporation. + Copyright (c) 2005, 2018, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, 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 @@ -2120,6 +2120,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) @@ -2155,6 +2156,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, See also mysql_uninstall_plugin() and initialize_audit_plugin() */ + mysql_audit_acquire_plugins(thd, event_class_mask); mysql_mutex_lock(&LOCK_plugin); @@ -2263,6 +2265,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) @@ -2270,6 +2273,16 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) DBUG_RETURN(TRUE); + if (!table->key_info) + { + my_printf_error(ER_UNKNOWN_ERROR, + "The table %s.%s has no primary key. " + "Please check the table definition and " + "create the primary key accordingly.", MYF(0), + table->s->db.str, table->s->table_name.str); + DBUG_RETURN(TRUE); + } + /* Pre-acquire audit plugins for events that may potentially occur during [UN]INSTALL PLUGIN. diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index b515578eb053a796dcdfe6cdae192541e71f5778..92d2b1c68b0ab82b608d5edce617e71ad60ccf2e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2736,6 +2736,15 @@ void mysql_sql_stmt_prepare(THD *thd) DBUG_VOID_RETURN; } +#if MYSQL_VERSION_ID < 100200 + /* + Backpoiting MDEV-14603 from 10.2 to 10.1 + Remove the code between #if..#endif when merging. + */ + Item_change_list change_list_save_point; + thd->change_list.move_elements_to(&change_list_save_point); +#endif + if (stmt->prepare(query, query_len)) { /* Statement map deletes the statement on erase */ @@ -2744,6 +2753,15 @@ void mysql_sql_stmt_prepare(THD *thd) else my_ok(thd, 0L, 0L, "Statement prepared"); +#if MYSQL_VERSION_ID < 100200 + /* + Backpoiting MDEV-14603 from 10.2 to 10.1 + Remove the code between #if..#endif when merging. + */ + thd->rollback_item_tree_changes(); + change_list_save_point.move_elements_to(&thd->change_list); +#endif + DBUG_VOID_RETURN; } @@ -3039,7 +3057,27 @@ void mysql_sql_stmt_execute(THD *thd) */ Item *free_list_backup= thd->free_list; thd->free_list= NULL; // Hide the external (e.g. "SET STATEMENT") Items + +#if MYSQL_VERSION_ID < 100200 + /* + Backpoiting MDEV-14603 from 10.2 to 10.1 + Remove the code between #if..#endif when merging. + */ + Item_change_list change_list_save_point; + thd->change_list.move_elements_to(&change_list_save_point); +#endif + (void) stmt->execute_loop(&expanded_query, FALSE, NULL, NULL); + +#if MYSQL_VERSION_ID < 100200 + /* + Backpoiting MDEV-14603 from 10.2 to 10.1 + Remove the code between #if..#endif when merging. + */ + thd->rollback_item_tree_changes(); + change_list_save_point.move_elements_to(&thd->change_list); +#endif + thd->free_items(); // Free items created by execute_loop() /* Now restore the "external" (e.g. "SET STATEMENT") Item list. @@ -3635,7 +3673,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) if (! (lex= new (mem_root) st_lex_local)) DBUG_RETURN(TRUE); - stmt_lex= lex; + lex->stmt_lex= lex; if (set_db(thd->db, thd->db_length)) DBUG_RETURN(TRUE); @@ -3920,7 +3958,7 @@ Prepared_statement::execute_loop(String *expanded_query, if (WSREP_ON) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); switch (thd->wsrep_conflict_state) { case CERT_FAILURE: @@ -3936,7 +3974,7 @@ Prepared_statement::execute_loop(String *expanded_query, default: break; } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -3958,7 +3996,6 @@ Prepared_statement::execute_loop(String *expanded_query, return error; } - bool Prepared_statement::execute_server_runnable(Server_runnable *server_runnable) { @@ -4168,6 +4205,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) Statement stmt_backup; Query_arena *old_stmt_arena; bool error= TRUE; + bool qc_executed= FALSE; char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= @@ -4290,6 +4328,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->lex->sql_command= SQLCOM_SELECT; status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]); thd->update_stats(); + qc_executed= TRUE; } } @@ -4328,7 +4367,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->set_statement(&stmt_backup); thd->stmt_arena= old_stmt_arena; - if (state == Query_arena::STMT_PREPARED) + if (state == Query_arena::STMT_PREPARED && !qc_executed) state= Query_arena::STMT_EXECUTED; if (error == 0 && this->lex->sql_command == SQLCOM_CALL) diff --git a/sql/sql_priv.h b/sql/sql_priv.h index ef3dd68065a911f4c078f4a0e389f1269800c100..e30060c8d3e7cf6436cfd004ab2c6ddeae11ee14 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2010, 2014, Monty Program Ab. +/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 35222bce949045698790b6b05698881cededcd55..4c164a3a621522e6bdc8b269962c562608279716 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -222,7 +222,7 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table, new_alias= (lower_case_table_names == 2) ? new_table->alias : new_table->table_name; - if (is_temporary_table(new_table)) + if (find_temporary_table(thd, new_table)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); DBUG_RETURN(1); // This can't be skipped diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index b5cca334891b86fb7835d1941770729a879f3d1d..569c3d2c4ef1b6cb80dd561991cf0e6797a5f61e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1904,11 +1904,8 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type, */ if (info->thd->variables.option_bits & OPTION_SKIP_REPLICATION) { - /* - The first byte of the packet is a '\0' to distinguish it from an error - packet. So the actual event starts at offset +1. - */ - uint16 event_flags= uint2korr(&((*packet)[FLAGS_OFFSET+1])); + uint16 event_flags= uint2korr(&((*packet)[FLAGS_OFFSET + ev_offset])); + if (event_flags & LOG_EVENT_SKIP_REPLICATION_F) return NULL; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 067c71205d014a7fa2dafa74c97cd3a7e11eed60..c52f74fbd4a3270fcb4b5a6d6d8150ae269a2593 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1148,9 +1148,6 @@ JOIN::optimize_inner() eval_select_list_used_tables(); - if (optimize_constant_subqueries()) - DBUG_RETURN(1); - table_count= select_lex->leaf_tables.elements; if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */ @@ -1212,6 +1209,9 @@ JOIN::optimize_inner() thd->restore_active_arena(arena, &backup); } + if (optimize_constant_subqueries()) + DBUG_RETURN(1); + if (setup_jtbm_semi_joins(this, join_list, &conds)) DBUG_RETURN(1); @@ -1250,10 +1250,19 @@ JOIN::optimize_inner() if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE || (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) { /* Impossible cond */ - DBUG_PRINT("info", (having_value == Item::COND_FALSE ? - "Impossible HAVING" : "Impossible WHERE")); - zero_result_cause= having_value == Item::COND_FALSE ? - "Impossible HAVING" : "Impossible WHERE"; + if (unit->select_limit_cnt) + { + DBUG_PRINT("info", (having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE")); + zero_result_cause= having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE"; + } + else + { + DBUG_PRINT("info", ("Zero limit")); + zero_result_cause= "Zero limit"; + conds= 0; + } table_count= top_join_tab_count= 0; error= 0; goto setup_subq_exit; @@ -25465,21 +25474,18 @@ void JOIN::set_allowed_join_cache_types() void JOIN::save_query_plan(Join_plan_state *save_to) { - if (keyuse.elements) - { - DYNAMIC_ARRAY tmp_keyuse; - /* Swap the current and the backup keyuse internal arrays. */ - tmp_keyuse= keyuse; - keyuse= save_to->keyuse; /* keyuse is reset to an empty array. */ - save_to->keyuse= tmp_keyuse; + DYNAMIC_ARRAY tmp_keyuse; + /* Swap the current and the backup keyuse internal arrays. */ + tmp_keyuse= keyuse; + keyuse= save_to->keyuse; /* keyuse is reset to an empty array. */ + save_to->keyuse= tmp_keyuse; - for (uint i= 0; i < table_count; i++) - { - save_to->join_tab_keyuse[i]= join_tab[i].keyuse; - join_tab[i].keyuse= NULL; - save_to->join_tab_checked_keys[i]= join_tab[i].checked_keys; - join_tab[i].checked_keys.clear_all(); - } + for (uint i= 0; i < table_count; i++) + { + save_to->join_tab_keyuse[i]= join_tab[i].keyuse; + join_tab[i].keyuse= NULL; + save_to->join_tab_checked_keys[i]= join_tab[i].checked_keys; + join_tab[i].checked_keys.clear_all(); } memcpy((uchar*) save_to->best_positions, (uchar*) best_positions, sizeof(POSITION) * (table_count + 1)); @@ -25517,20 +25523,17 @@ void JOIN::reset_query_plan() void JOIN::restore_query_plan(Join_plan_state *restore_from) { - if (restore_from->keyuse.elements) - { - DYNAMIC_ARRAY tmp_keyuse; - tmp_keyuse= keyuse; - keyuse= restore_from->keyuse; - restore_from->keyuse= tmp_keyuse; - - for (uint i= 0; i < table_count; i++) - { - join_tab[i].keyuse= restore_from->join_tab_keyuse[i]; - join_tab[i].checked_keys= restore_from->join_tab_checked_keys[i]; - } + DYNAMIC_ARRAY tmp_keyuse; + tmp_keyuse= keyuse; + keyuse= restore_from->keyuse; + restore_from->keyuse= tmp_keyuse; + for (uint i= 0; i < table_count; i++) + { + join_tab[i].keyuse= restore_from->join_tab_keyuse[i]; + join_tab[i].checked_keys= restore_from->join_tab_checked_keys[i]; } + memcpy((uchar*) best_positions, (uchar*) restore_from->best_positions, sizeof(POSITION) * (table_count + 1)); /* Restore SJM nests */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 5a78a27a90719b06e272bd3e3da2af6ec965db22..bbf2cb30b978513e7375171f859675cc934ec17f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2437,16 +2437,16 @@ static const char *thread_state_info(THD *tmp) else return "Reading from net"; } - else +#else + if (tmp->get_command() == COM_SLEEP) + return ""; #endif - { - if (tmp->proc_info) - return tmp->proc_info; - else if (tmp->mysys_var && tmp->mysys_var->current_cond) - return "Waiting on cond"; - else - return NULL; - } + if (tmp->proc_info) + return tmp->proc_info; + else if (tmp->mysys_var && tmp->mysys_var->current_cond) + return "Waiting on cond"; + else + return NULL; } void mysqld_list_processes(THD *thd,const char *user, bool verbose) @@ -3483,6 +3483,13 @@ extern ST_SCHEMA_TABLE schema_tables[]; bool schema_table_store_record(THD *thd, TABLE *table) { int error; + + if (thd->killed) + { + thd->send_kill_message(); + return 1; + } + if ((error= table->file->ha_write_tmp_row(table->record[0]))) { TMP_TABLE_PARAM *param= table->pos_in_table_list->schema_table_param; @@ -9763,3 +9770,88 @@ static void get_cs_converted_string_value(THD *thd, return; } #endif + +/** + Dumps a text description of a thread, its security context + (user, host) and the current query. + + @param thd thread context + @param buffer pointer to preferred result buffer + @param length length of buffer + @param max_query_len how many chars of query to copy (0 for all) + + @return Pointer to string +*/ + +extern "C" +char *thd_get_error_context_description(THD *thd, char *buffer, + unsigned int length, + unsigned int max_query_len) +{ + String str(buffer, length, &my_charset_latin1); + const Security_context *sctx= &thd->main_security_ctx; + char header[256]; + int len; + + mysql_mutex_lock(&LOCK_thread_count); + + len= my_snprintf(header, sizeof(header), + "MySQL thread id %lu, OS thread handle 0x%lx, query id %lu", + thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id); + str.length(0); + str.append(header, len); + + if (sctx->host) + { + str.append(' '); + str.append(sctx->host); + } + + if (sctx->ip) + { + str.append(' '); + str.append(sctx->ip); + } + + if (sctx->user) + { + str.append(' '); + str.append(sctx->user); + } + + /* Don't wait if LOCK_thd_data is used as this could cause a deadlock */ + if (!mysql_mutex_trylock(&thd->LOCK_thd_data)) + { + if (const char *info= thread_state_info(thd)) + { + str.append(' '); + str.append(info); + } + + if (thd->query()) + { + if (max_query_len < 1) + len= thd->query_length(); + else + len= MY_MIN(thd->query_length(), max_query_len); + str.append('\n'); + str.append(thd->query(), len); + } + mysql_mutex_unlock(&thd->LOCK_thd_data); + } + mysql_mutex_unlock(&LOCK_thread_count); + + if (str.c_ptr_safe() == buffer) + return buffer; + + /* + We have to copy the new string to the destination buffer because the string + was reallocated to a larger buffer to be able to fit. + */ + DBUG_ASSERT(buffer != NULL); + length= MY_MIN(str.length(), length-1); + memcpy(buffer, str.c_ptr_quick(), length); + /* Make sure that the new string is null terminated */ + buffer[length]= '\0'; + return buffer; +} diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 1e8e959314b7c2d670d0ed76e84c29e3088184a7..b7ccbb5c212b3d3778f9c00257b1704a799c5bf5 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1518,7 +1518,8 @@ class Stat_table_write_iter ~Stat_table_write_iter() { - cleanup(); + /* Ensure that cleanup has been run */ + DBUG_ASSERT(rowid_buf == 0); } }; @@ -2617,7 +2618,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) DBUG_ENTER("collect_statistics_for_index"); /* No statistics for FULLTEXT indexes. */ - if (key_info->flags & HA_FULLTEXT) + if (key_info->flags & (HA_FULLTEXT|HA_SPATIAL)) DBUG_RETURN(rc); Index_prefix_calc index_prefix_calc(table, key_info); @@ -3083,18 +3084,19 @@ bool statistics_for_tables_is_needed(THD *thd, TABLE_LIST *tables) return FALSE; /* - Do not read statistics for any query over non-user tables. - If the query references some statistical tables, but not all - of them, reading the statistics may lead to a deadlock - */ + Do not read statistics for any query that explicity involves + statistical tables, failure to to do so we may end up + in a deadlock. + */ + for (TABLE_LIST *tl= tables; tl; tl= tl->next_global) { if (!tl->is_view_or_derived() && tl->table) { TABLE_SHARE *table_share= tl->table->s; if (table_share && - (table_share->table_category != TABLE_CATEGORY_USER || - table_share->tmp_table != NO_TMP_TABLE)) + table_share->table_category != TABLE_CATEGORY_USER + && is_stat_table(tl->db, tl->alias)) return FALSE; } } @@ -3767,6 +3769,15 @@ double get_column_range_cardinality(Field *field, if (!col_stats) return tab_records; + /* + Use statistics for a table only when we have actually read + the statistics from the stat tables. For example due to + chances of getting a deadlock we disable reading statistics for + a table. + */ + + if (!table->stats_is_read) + return tab_records; double col_nulls= tab_records * col_stats->get_nulls_ratio(); @@ -3980,14 +3991,13 @@ bool is_stat_table(const char *db, const char *table) { DBUG_ASSERT(db && table); - if (!memcmp(db, stat_tables_db_name.str, stat_tables_db_name.length)) + if (!my_strcasecmp(table_alias_charset, db, stat_tables_db_name.str)) { for (uint i= 0; i < STATISTICS_TABLES; i ++) { - if (!memcmp(table, stat_table_name[i].str, stat_table_name[i].length)) + if (!my_strcasecmp(table_alias_charset, table, stat_table_name[i].str)) return true; } } return false; } - diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 20772adcb22ce558a8a0c6e9c3627b9ee3e1a07e..c22e33182c6ab9644e53d271004c89580eacc41b 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -183,7 +183,16 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs) { if (alloc(arg_length)) return TRUE; - if ((str_length=arg_length)) + if (Ptr == str && arg_length == str_length) + { + /* + This can happen in some cases. This code is here mainly to avoid + warnings from valgrind, but can also be an indication of error. + */ + DBUG_PRINT("warning", ("Copying string on itself: %p %u", + str, arg_length)); + } + else if ((str_length=arg_length)) memcpy(Ptr,str,arg_length); Ptr[arg_length]=0; str_charset=cs; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 44df4bba7677c16534cb1ade296ba091bd920ff5..3c9146354d609a4ec5c636e6b21aae08c2f4175d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 2018, MariaDB 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 @@ -4198,7 +4198,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, /* Give warnings for not supported table options */ #if defined(WITH_ARIA_STORAGE_ENGINE) extern handlerton *maria_hton; - if (file->ht != maria_hton) + if (file->partition_ht() != maria_hton) #endif if (create_info->transactional) push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, @@ -5071,7 +5071,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, This should always work as we have a meta lock on the table. */ thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); result= 1; @@ -5429,7 +5429,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, This should always work as we have a meta lock on the table. */ thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); res= 1; // We got an error @@ -5835,10 +5835,28 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info) List_iterator drop_it(alter_info->drop_list); Alter_drop *drop; bool remove_drop; + ulonglong left_flags= 0; while ((drop= drop_it++)) { + ulonglong cur_flag= 0; + switch (drop->type) { + case Alter_drop::COLUMN: + cur_flag= Alter_info::ALTER_DROP_COLUMN; + break; + case Alter_drop::FOREIGN_KEY: + cur_flag= Alter_info::DROP_FOREIGN_KEY; + break; + case Alter_drop::KEY: + cur_flag= Alter_info::ALTER_DROP_INDEX; + break; + default: + break; + } if (!drop->drop_if_exists) + { + left_flags|= cur_flag; continue; + } remove_drop= TRUE; if (drop->type == Alter_drop::COLUMN) { @@ -5915,12 +5933,15 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info) ER_THD(thd, ER_CANT_DROP_FIELD_OR_KEY), drop->name); drop_it.remove(); - if (alter_info->drop_list.is_empty()) - alter_info->flags&= ~(Alter_info::ALTER_DROP_COLUMN | - Alter_info::ALTER_DROP_INDEX | - Alter_info::DROP_FOREIGN_KEY); } + else + left_flags|= cur_flag; } + /* Reset state to what's left in drop list */ + alter_info->flags&= ~(Alter_info::ALTER_DROP_COLUMN | + Alter_info::ALTER_DROP_INDEX | + Alter_info::DROP_FOREIGN_KEY); + alter_info->flags|= left_flags; } /* ALTER TABLE ADD KEY IF NOT EXISTS */ @@ -5936,8 +5957,11 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info) continue; /* Check if the table already has a PRIMARY KEY */ - bool dup_primary_key= key->type == Key::PRIMARY && - table->s->primary_key != MAX_KEY; + bool dup_primary_key= + key->type == Key::PRIMARY && + table->s->primary_key != MAX_KEY && + (keyname= table->s->key_info[table->s->primary_key].name) && + my_strcasecmp(system_charset_info, keyname, primary_key_name) == 0; if (dup_primary_key) goto remove_key; @@ -7294,7 +7318,7 @@ static bool mysql_inplace_alter_table(THD *thd, HA_EXTRA_PREPARE_FOR_RENAME : HA_EXTRA_NOT_USED, NULL); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); /* QQ; do something about metadata locks ? */ } @@ -9300,7 +9324,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, end_inplace: - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) goto err_with_mdl_after_alter; THD_STAGE_INFO(thd, stage_end); @@ -9414,9 +9438,7 @@ bool mysql_trans_prepare_alter_copy_data(THD *thd) This needs to be done before external_lock. */ - if (ha_enable_transaction(thd, FALSE)) - DBUG_RETURN(TRUE); - DBUG_RETURN(FALSE); + DBUG_RETURN(ha_enable_transaction(thd, FALSE) != 0); } @@ -9472,6 +9494,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, ha_rows examined_rows; ha_rows found_rows; bool auto_increment_field_copied= 0; + bool cleanup_done= 0; ulonglong save_sql_mode= thd->variables.sql_mode; ulonglong prev_insert_id, time_to_report_progress; Field **dfield_ptr= to->default_field; @@ -9480,15 +9503,23 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, /* Two or 3 stages; Sorting, copying data and update indexes */ thd_progress_init(thd, 2 + MY_TEST(order)); - if (mysql_trans_prepare_alter_copy_data(thd)) - DBUG_RETURN(-1); - if (!(copy= new Copy_field[to->s->fields])) DBUG_RETURN(-1); /* purecov: inspected */ + if (mysql_trans_prepare_alter_copy_data(thd)) + { + delete [] copy; + DBUG_RETURN(-1); + } + /* We need external lock before we can disable/enable keys */ if (to->file->ha_external_lock(thd, F_WRLCK)) + { + /* Undo call to mysql_trans_prepare_alter_copy_data() */ + ha_enable_transaction(thd, TRUE); + delete [] copy; DBUG_RETURN(-1); + } alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff); @@ -9498,7 +9529,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, from->file->info(HA_STATUS_VARIABLE); to->file->ha_start_bulk_insert(from->file->stats.records, ignore ? 0 : HA_CREATE_UNIQUE_INDEX_BY_SORT); - List_iterator it(create); Create_field *def; copy_end=copy; @@ -9702,7 +9732,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, } end_read_record(&info); free_io_cache(from); - delete [] copy; THD_STAGE_INFO(thd, stage_enabling_keys); thd_progress_next_stage(thd); @@ -9717,6 +9746,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, to->file->print_error(my_errno,MYF(0)); error= 1; } + cleanup_done= 1; to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); if (mysql_trans_commit_alter_copy_data(thd)) @@ -9728,6 +9758,16 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, *copied= found_count; *deleted=delete_count; to->file->ha_release_auto_increment(); + delete [] copy; + + if (!cleanup_done) + { + /* This happens if we get an error during initialzation of data */ + DBUG_ASSERT(error); + to->file->ha_end_bulk_insert(); + ha_enable_transaction(thd, TRUE); + } + if (to->file->ha_external_lock(thd,F_UNLCK)) error=1; if (error < 0 && to->file->extra(HA_EXTRA_PREPARE_FOR_RENAME)) diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 2e2c5932c2a7ca4f98945d5493299ee7b0ce899a..6323538f193cf62bc7c87a7b082b8d5d5b1fef13 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -959,6 +959,8 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, ltime->day= 0; return 0; } + else if (ltime->neg) + goto invalid_date; if (int_type != INTERVAL_DAY) ltime->time_type= MYSQL_TIMESTAMP_DATETIME; // Return full date diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 70e9b36c56e3ce25e1888baff418018fdaf8fa2a..d9999e2aab7dd31dd9ac01152401018aa81c8818 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2004, 2012, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, MariaDB 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 @@ -441,7 +442,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) my_error(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, MYF(0)); DBUG_RETURN(TRUE); } - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) if (!create) { @@ -503,6 +503,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (err_status) goto end; } + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* We should have only one table in table list. */ DBUG_ASSERT(tables->next_global == 0); @@ -576,7 +577,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) Ignore the return value for now. It's better to keep master/slave in consistent state. */ - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) thd->clear_error(); /* @@ -613,6 +614,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) #endif /* WITH_WSREP */ } + /** Build stmt_query to write it in the bin-log and get the trigger definer. @@ -1060,6 +1062,11 @@ Table_triggers_list::~Table_triggers_list() for (int j= 0; j < (int)TRG_ACTION_MAX; j++) delete bodies[i][j]; + /* Free blobs used in insert */ + if (record0_field) + for (Field **fld_ptr= record0_field; *fld_ptr; fld_ptr++) + (*fld_ptr)->free(); + if (record1_field) for (Field **fld_ptr= record1_field; *fld_ptr; fld_ptr++) delete *fld_ptr; @@ -1373,13 +1380,13 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, List_iterator_fast it_client_cs_name(triggers->client_cs_names); List_iterator_fast it_connection_cl_name(triggers->connection_cl_names); List_iterator_fast it_db_cl_name(triggers->db_cl_names); - LEX *old_lex= thd->lex, *old_stmt_lex= thd->stmt_lex; + LEX *old_lex= thd->lex; LEX lex; sp_rcontext *save_spcont= thd->spcont; ulonglong save_sql_mode= thd->variables.sql_mode; LEX_STRING *on_table_name; - thd->lex= thd->stmt_lex= &lex; + thd->lex= &lex; save_db.str= thd->db; save_db.length= thd->db_length; @@ -1578,7 +1585,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, } thd->reset_db(save_db.str, save_db.length); thd->lex= old_lex; - thd->stmt_lex= old_stmt_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; @@ -1591,7 +1597,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, // QQ: anything else ? lex_end(&lex); thd->lex= old_lex; - thd->stmt_lex= old_stmt_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; thd->reset_db(save_db.str, save_db.length); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index c08c75f771abde1095d5d7d672e700a805cea992..8a70e6f6bdbc0200c9abcea39b4df1eda2b2ce28 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2010, 2015, Oracle and/or its affiliates. - Copyright (c) 2013, 2015, MariaDB + Copyright (c) 2012, 2018, MariaDB 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 @@ -426,7 +426,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) */ error= dd_recreate_table(thd, table_ref->db, table_ref->table_name); - if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd, false)) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); /* No need to binlog a failed truncate-by-recreate. */ @@ -500,4 +500,3 @@ bool Sql_cmd_truncate_table::execute(THD *thd) DBUG_RETURN(res); } - diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 1bdc76a66ea00c4e8105f5c08b86e9d4ac16d0e3..6bd6b6a7b639dadefa6754922bf883cee3a31315 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -428,8 +428,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, lex->link_first_table_back(view, link_to_local); view->open_type= OT_BASE_ONLY; - - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) + WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* ignore lock specs for CREATE statement @@ -692,15 +691,15 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, lex->link_first_table_back(view, link_to_local); DBUG_RETURN(0); +#ifdef WITH_WSREP + error: + res= TRUE; +#endif /* WITH_WSREP */ err: THD_STAGE_INFO(thd, stage_end); lex->link_first_table_back(view, link_to_local); unit->cleanup(); DBUG_RETURN(res || thd->is_error()); -#ifdef WITH_WSREP - error: - DBUG_RETURN(true); -#endif /* WITH_WSREP */ } @@ -1315,6 +1314,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, now Lex placed in statement memory */ + table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local; if (!table->view) { @@ -1340,8 +1340,9 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, goto end; lex_start(thd); + lex->stmt_lex= old_lex; view_select= &lex->select_lex; - view_select->select_number= ++thd->stmt_lex->current_select_number; + view_select->select_number= ++thd->lex->stmt_lex->current_select_number; ulonglong saved_mode= thd->variables.sql_mode; /* switch off modes which can prevent normal parsing of VIEW diff --git a/sql/sql_yacc.cc b/sql/sql_yacc.cc index 99944f1a0e3e0f31f1a535024656f591de7767c7..caac1c428ff2cb2107678104f702e31209d924a5 100644 --- a/sql/sql_yacc.cc +++ b/sql/sql_yacc.cc @@ -3025,39 +3025,39 @@ static const yytype_uint16 yyrline[] = 14341, 14346, 14345, 14352, 14351, 14361, 14360, 14371, 14370, 14376, 14384, 14386, 14391, 14391, 14400, 14399, 14413, 14412, 14417, 14421, 14422, 14423, 14427, 14428, 14429, 14430, 14434, 14435, 14436, 14437, - 14442, 14466, 14492, 14503, 14515, 14529, 14544, 14563, 14580, 14592, - 14600, 14616, 14642, 14679, 14693, 14694, 14695, 14696, 14700, 14718, - 14736, 14737, 14741, 14742, 14743, 14744, 14748, 14762, 14766, 14767, - 14768, 14778, 14779, 14780, 14786, 14792, 14804, 14803, 14816, 14817, - 14821, 14822, 14826, 14841, 14842, 14843, 14848, 14849, 14854, 14853, - 14870, 14879, 14889, 14888, 14919, 14920, 14924, 14925, 14929, 14930, - 14931, 14932, 14934, 14933, 14946, 14947, 14948, 14949, 14950, 14956, - 14961, 14967, 14978, 14989, 14993, 15000, 15009, 15011, 15016, 15021, - 15028, 15040, 15052, 15059, 15071, 15072, 15075, 15076, 15079, 15084, - 15092, 15102, 15121, 15124, 15126, 15130, 15131, 15138, 15140, 15144, - 15145, 15150, 15149, 15153, 15152, 15156, 15155, 15159, 15158, 15161, - 15162, 15163, 15164, 15165, 15166, 15167, 15168, 15169, 15170, 15171, - 15172, 15173, 15174, 15175, 15176, 15177, 15178, 15179, 15180, 15181, - 15182, 15183, 15184, 15185, 15186, 15190, 15191, 15195, 15196, 15200, - 15207, 15214, 15224, 15235, 15244, 15253, 15265, 15270, 15278, 15283, - 15291, 15296, 15303, 15303, 15304, 15304, 15307, 15314, 15319, 15325, - 15331, 15337, 15341, 15345, 15346, 15350, 15378, 15380, 15384, 15388, - 15392, 15399, 15400, 15404, 15405, 15409, 15410, 15414, 15415, 15421, - 15427, 15433, 15439, 15449, 15448, 15458, 15467, 15468, 15472, 15473, - 15478, 15479, 15480, 15485, 15486, 15487, 15491, 15492, 15496, 15508, - 15517, 15527, 15536, 15550, 15551, 15556, 15555, 15571, 15572, 15576, - 15577, 15581, 15581, 15602, 15603, 15607, 15608, 15609, 15613, 15618, - 15626, 15629, 15627, 15642, 15649, 15670, 15694, 15696, 15700, 15701, - 15705, 15706, 15714, 15715, 15716, 15717, 15723, 15729, 15739, 15741, - 15743, 15748, 15749, 15750, 15751, 15752, 15756, 15757, 15758, 15759, - 15760, 15761, 15771, 15772, 15777, 15790, 15806, 15808, 15810, 15816, - 15817, 15819, 15825, 15824, 15843, 15844, 15848, 15854, 15863, 15863, - 15887, 15888, 15893, 15894, 15896, 15898, 15912, 15921, 15927, 15932, - 15909, 15982, 15983, 15987, 16007, 16028, 16032, 16038, 16044, 16003, - 16103, 16115, 16124, 16128, 16102, 16145, 16149, 16153, 16157, 16161, - 16165, 16172, 16179, 16186, 16196, 16197, 16201, 16202, 16203, 16207, - 16208, 16213, 16215, 16214, 16220, 16221, 16225, 16232, 16242, 16248, - 16259 + 14442, 14466, 14492, 14503, 14520, 14534, 14549, 14568, 14585, 14597, + 14605, 14621, 14647, 14684, 14698, 14699, 14700, 14701, 14705, 14723, + 14741, 14742, 14746, 14747, 14748, 14749, 14753, 14767, 14771, 14772, + 14773, 14783, 14784, 14785, 14791, 14797, 14809, 14808, 14821, 14822, + 14826, 14827, 14831, 14846, 14847, 14848, 14853, 14854, 14859, 14858, + 14875, 14884, 14894, 14893, 14924, 14925, 14929, 14930, 14934, 14935, + 14936, 14937, 14939, 14938, 14951, 14952, 14953, 14954, 14955, 14961, + 14966, 14972, 14983, 14994, 14998, 15005, 15014, 15016, 15021, 15026, + 15033, 15045, 15057, 15064, 15076, 15077, 15080, 15081, 15084, 15089, + 15097, 15107, 15126, 15129, 15131, 15135, 15136, 15143, 15145, 15149, + 15150, 15155, 15154, 15158, 15157, 15161, 15160, 15164, 15163, 15166, + 15167, 15168, 15169, 15170, 15171, 15172, 15173, 15174, 15175, 15176, + 15177, 15178, 15179, 15180, 15181, 15182, 15183, 15184, 15185, 15186, + 15187, 15188, 15189, 15190, 15191, 15195, 15196, 15200, 15201, 15205, + 15212, 15219, 15229, 15240, 15249, 15258, 15270, 15275, 15283, 15288, + 15296, 15301, 15308, 15308, 15309, 15309, 15312, 15319, 15324, 15330, + 15336, 15342, 15346, 15350, 15351, 15355, 15383, 15385, 15389, 15393, + 15397, 15404, 15405, 15409, 15410, 15414, 15415, 15419, 15420, 15426, + 15432, 15438, 15444, 15454, 15453, 15463, 15472, 15473, 15477, 15478, + 15483, 15484, 15485, 15490, 15491, 15492, 15496, 15497, 15501, 15513, + 15522, 15532, 15541, 15555, 15556, 15561, 15560, 15576, 15577, 15581, + 15582, 15586, 15586, 15607, 15608, 15612, 15613, 15614, 15618, 15623, + 15631, 15634, 15632, 15647, 15654, 15675, 15699, 15701, 15705, 15706, + 15710, 15711, 15719, 15720, 15721, 15722, 15728, 15734, 15744, 15746, + 15748, 15753, 15754, 15755, 15756, 15757, 15761, 15762, 15763, 15764, + 15765, 15766, 15776, 15777, 15782, 15795, 15811, 15813, 15815, 15821, + 15822, 15824, 15830, 15829, 15848, 15849, 15853, 15859, 15868, 15868, + 15892, 15893, 15898, 15899, 15901, 15903, 15917, 15926, 15932, 15937, + 15914, 15987, 15988, 15992, 16012, 16033, 16037, 16043, 16049, 16008, + 16108, 16120, 16129, 16133, 16107, 16150, 16154, 16158, 16162, 16166, + 16170, 16177, 16184, 16191, 16201, 16202, 16206, 16207, 16208, 16212, + 16213, 16218, 16220, 16219, 16225, 16226, 16230, 16237, 16247, 16253, + 16264 }; #endif @@ -38803,6 +38803,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); #line 14504 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { struct sys_var_with_base tmp= (yyvsp[-2].variable); + if (tmp.var == trg_new_row_fake_var) + { + my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), "NEW"); + MYSQL_YYABORT; + } /* Lookup if necessary: must be a system variable. */ if (tmp.var == NULL) { @@ -38812,11 +38817,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (set_system_variable(thd, &tmp, (yyvsp[-3].var_type), (yyvsp[0].item))) MYSQL_YYABORT; } -#line 38816 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38821 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2544: -#line 14516 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14521 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; CHARSET_INFO *cs2; @@ -38830,11 +38835,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } -#line 38834 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38839 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2545: -#line 14530 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14535 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; sp_pcontext *spc= lex->spcont; @@ -38849,11 +38854,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; } -#line 38853 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38858 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2546: -#line 14545 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14550 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; CHARSET_INFO *cs2; @@ -38872,11 +38877,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } -#line 38876 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38881 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2547: -#line 14564 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14569 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex = Lex; LEX_USER *user; @@ -38893,11 +38898,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } -#line 38897 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38902 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2548: -#line 14581 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14586 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex = Lex; set_var_default_role *var= (new (thd->mem_root) @@ -38909,11 +38914,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } -#line 38913 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38918 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2549: -#line 14593 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14598 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex = Lex; set_var_role *var= new (thd->mem_root) set_var_role((yyvsp[0].lex_str)); @@ -38921,11 +38926,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } -#line 38925 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38930 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2550: -#line 14601 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14606 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex = Lex; set_var_password *var= (new (thd->mem_root) @@ -38937,11 +38942,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } -#line 38941 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38946 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2551: -#line 14617 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14622 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { sp_pcontext *spc= thd->lex->spcont; sp_variable *spv; @@ -38967,11 +38972,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.variable).base_name= (yyvsp[0].lex_str); } } -#line 38971 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 38976 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2552: -#line 14643 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14648 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (check_reserved_words(&(yyvsp[-2].lex_str))) @@ -39008,11 +39013,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.variable).base_name= (yyvsp[-2].lex_str); } } -#line 39012 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39017 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2553: -#line 14680 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14685 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { sys_var *tmp=find_sys_var(thd, (yyvsp[0].lex_str).str, (yyvsp[0].lex_str).length); if (!tmp) @@ -39023,11 +39028,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.variable).base_name.str= (char*) "default"; (yyval.variable).base_name.length= 7; } -#line 39027 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39032 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2558: -#line 14701 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14706 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; Item *item= new (thd->mem_root) Item_int(thd, (int32) (yyvsp[0].num)); @@ -39042,11 +39047,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } -#line 39046 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39051 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2559: -#line 14719 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14724 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; Item *item= new (thd->mem_root) Item_int(thd, (int32) (yyvsp[0].tx_isolation)); @@ -39061,47 +39066,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } -#line 39065 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39070 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2560: -#line 14736 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14741 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= true; } -#line 39071 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39076 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2561: -#line 14737 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14742 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= false; } -#line 39077 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39082 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2562: -#line 14741 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14746 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.tx_isolation)= ISO_READ_UNCOMMITTED; } -#line 39083 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39088 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2563: -#line 14742 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14747 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.tx_isolation)= ISO_READ_COMMITTED; } -#line 39089 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39094 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2564: -#line 14743 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14748 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.tx_isolation)= ISO_REPEATABLE_READ; } -#line 39095 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39100 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2565: -#line 14744 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14749 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.tx_isolation)= ISO_SERIALIZABLE; } -#line 39101 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39106 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2566: -#line 14749 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14754 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; sp_pcontext *spc= lex->spcont; @@ -39115,82 +39120,82 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->definer->plugin= empty_lex_str; lex->definer->auth= empty_lex_str; } -#line 39119 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39124 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2567: -#line 14762 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14767 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer= (yyvsp[-1].lex_user); } -#line 39125 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39130 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2568: -#line 14766 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14771 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer->pwhash= (yyvsp[0].lex_str);} -#line 39131 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39136 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2569: -#line 14767 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14772 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer->pwtext= (yyvsp[-1].lex_str); } -#line 39137 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39142 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2570: -#line 14769 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14774 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer->pwtext= (yyvsp[-1].lex_str); Lex->definer->pwhash.str= Item_func_password::alloc(thd, (yyvsp[-1].lex_str).str, (yyvsp[-1].lex_str).length, Item_func_password::OLD); Lex->definer->pwhash.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } -#line 39148 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39153 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2571: -#line 14778 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14783 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.item)=(yyvsp[0].item); } -#line 39154 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39159 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2572: -#line 14779 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14784 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.item)=0; } -#line 39160 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39165 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2573: -#line 14781 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14786 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.item)=new (thd->mem_root) Item_string_sys(thd, "ON", 2); if ((yyval.item) == NULL) MYSQL_YYABORT; } -#line 39170 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39175 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2574: -#line 14787 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14792 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.item)=new (thd->mem_root) Item_string_sys(thd, "ALL", 3); if ((yyval.item) == NULL) MYSQL_YYABORT; } -#line 39180 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39185 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2575: -#line 14793 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14798 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.item)=new (thd->mem_root) Item_string_sys(thd, "binary", 6); if ((yyval.item) == NULL) MYSQL_YYABORT; } -#line 39190 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39195 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2576: -#line 14804 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14809 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; @@ -39198,29 +39203,29 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "LOCK")); lex->sql_command= SQLCOM_LOCK_TABLES; } -#line 39202 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39207 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2577: -#line 14812 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14817 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39208 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39213 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2578: -#line 14816 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14821 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { } -#line 39214 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39219 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2579: -#line 14817 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14822 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { } -#line 39220 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39225 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2582: -#line 14827 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14832 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { thr_lock_type lock_type= (thr_lock_type) (yyvsp[0].num); bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE); @@ -39232,43 +39237,43 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MDL_SHARED_READ))) MYSQL_YYABORT; } -#line 39236 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39241 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2583: -#line 14841 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14846 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= TL_READ_NO_INSERT; } -#line 39242 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39247 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2584: -#line 14842 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14847 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= TL_WRITE_DEFAULT; } -#line 39248 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39253 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2585: -#line 14844 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14849 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); } -#line 39256 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39261 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2586: -#line 14848 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14853 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= TL_WRITE_LOW_PRIORITY; } -#line 39262 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39267 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2587: -#line 14849 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14854 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= TL_READ; } -#line 39268 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39273 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2588: -#line 14854 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14859 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; @@ -39276,17 +39281,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "UNLOCK")); lex->sql_command= SQLCOM_UNLOCK_TABLES; } -#line 39280 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39285 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2589: -#line 14862 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14867 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39286 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39291 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2590: -#line 14871 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14876 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->sphead) @@ -39295,11 +39300,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (!lex->current_select->add_table_to_list(thd, (yyvsp[-2].table), (yyvsp[0].lex_str_ptr), 0)) MYSQL_YYABORT; } -#line 39299 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39304 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2591: -#line 14880 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14885 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->sphead) @@ -39308,11 +39313,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (!lex->current_select->add_table_to_list(thd, (yyvsp[-1].table), 0, 0)) MYSQL_YYABORT; } -#line 39312 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39317 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2592: -#line 14889 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14894 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (lex->sphead) @@ -39329,11 +39334,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (!lex->current_select->add_table_to_list(thd, (yyvsp[-1].table), 0, 0)) MYSQL_YYABORT; } -#line 39333 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39338 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2593: -#line 14906 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14911 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->expr_allows_subselect= TRUE; /* Stored functions are not supported for HANDLER READ. */ @@ -39344,59 +39349,59 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; } } -#line 39348 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39353 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2594: -#line 14919 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14924 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ident= null_lex_str; } -#line 39354 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39359 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2595: -#line 14920 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14925 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ident= (yyvsp[-1].lex_str); } -#line 39360 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39365 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2596: -#line 14924 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14929 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RFIRST; } -#line 39366 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39371 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2597: -#line 14925 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14930 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RNEXT; } -#line 39372 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39377 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2598: -#line 14929 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14934 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RFIRST; } -#line 39378 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39383 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2599: -#line 14930 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14935 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RNEXT; } -#line 39384 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39389 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2600: -#line 14931 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14936 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RPREV; } -#line 39390 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39395 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2601: -#line 14932 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14937 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ha_read_mode = RLAST; } -#line 39396 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39401 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2602: -#line 14934 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14939 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->ha_read_mode = RKEY; @@ -39404,63 +39409,63 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (!(lex->insert_list= new (thd->mem_root) List_item)) MYSQL_YYABORT; } -#line 39408 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39413 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2603: -#line 14942 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14947 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39414 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39419 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2604: -#line 14946 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14951 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.ha_rkey_mode)=HA_READ_KEY_EXACT; } -#line 39420 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39425 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2605: -#line 14947 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14952 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.ha_rkey_mode)=HA_READ_KEY_OR_NEXT; } -#line 39426 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39431 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2606: -#line 14948 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14953 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.ha_rkey_mode)=HA_READ_KEY_OR_PREV; } -#line 39432 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39437 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2607: -#line 14949 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14954 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.ha_rkey_mode)=HA_READ_AFTER_KEY; } -#line 39438 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39443 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2608: -#line 14950 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14955 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.ha_rkey_mode)=HA_READ_BEFORE_KEY; } -#line 39444 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39449 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2609: -#line 14957 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14962 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39450 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39455 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2610: -#line 14962 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14967 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_REVOKE; lex->type= 0; } -#line 39460 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39465 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2611: -#line 14968 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14973 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->columns.elements) @@ -39471,11 +39476,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sql_command= SQLCOM_REVOKE; lex->type= TYPE_ENUM_FUNCTION; } -#line 39475 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39480 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2612: -#line 14979 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14984 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->columns.elements) @@ -39486,68 +39491,68 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sql_command= SQLCOM_REVOKE; lex->type= TYPE_ENUM_PROCEDURE; } -#line 39490 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39495 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2613: -#line 14990 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14995 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_REVOKE_ALL; } -#line 39498 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39503 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2614: -#line 14994 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 14999 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->users_list.push_front ((yyvsp[-2].lex_user)); lex->sql_command= SQLCOM_REVOKE; lex->type= TYPE_ENUM_PROXY; } -#line 39509 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39514 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2615: -#line 15001 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15006 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command= SQLCOM_REVOKE_ROLE; if (Lex->users_list.push_front((yyvsp[-2].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 39519 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39524 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2616: -#line 15010 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15015 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->with_admin_option= true; (yyval.lex_user)= (yyvsp[0].lex_user); } -#line 39525 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39530 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2617: -#line 15012 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15017 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->with_admin_option= false; (yyval.lex_user)= (yyvsp[0].lex_user); } -#line 39531 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39536 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2618: -#line 15017 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15022 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39537 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39542 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2619: -#line 15023 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15028 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_GRANT; lex->type= 0; } -#line 39547 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39552 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2620: -#line 15030 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15035 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->columns.elements) @@ -39558,11 +39563,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sql_command= SQLCOM_GRANT; lex->type= TYPE_ENUM_FUNCTION; } -#line 39562 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39567 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2621: -#line 15042 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15047 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; if (lex->columns.elements) @@ -39573,22 +39578,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sql_command= SQLCOM_GRANT; lex->type= TYPE_ENUM_PROCEDURE; } -#line 39577 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39582 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2622: -#line 15053 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15058 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->users_list.push_front ((yyvsp[-3].lex_user)); lex->sql_command= SQLCOM_GRANT; lex->type= TYPE_ENUM_PROXY; } -#line 39588 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39593 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2623: -#line 15060 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15065 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_GRANT_ROLE; @@ -39596,64 +39601,64 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (Lex->users_list.push_front((yyvsp[-3].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 39600 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39605 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2624: -#line 15071 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15076 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer = 0; } -#line 39606 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39611 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2625: -#line 15072 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15077 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer = (yyvsp[0].lex_user); } -#line 39612 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39617 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2626: -#line 15075 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15080 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->with_admin_option= false; } -#line 39618 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39623 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2627: -#line 15076 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15081 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->with_admin_option= true; } -#line 39624 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39629 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2628: -#line 15080 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15085 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 39633 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39638 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2629: -#line 15085 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15090 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 39642 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39647 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2630: -#line 15093 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15098 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (!((yyval.lex_user)=(LEX_USER*) thd->calloc(sizeof(LEX_USER)))) MYSQL_YYABORT; (yyval.lex_user)->user= current_role; (yyval.lex_user)->reset_auth(); } -#line 39653 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39658 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2631: -#line 15103 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15108 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { CHARSET_INFO *cs= system_charset_info; /* trim end spaces (as they'll be lost in mysql.user anyway) */ @@ -39672,275 +39677,275 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); cs, 0)) MYSQL_YYABORT; } -#line 39676 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39681 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2635: -#line 15130 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15135 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39682 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39687 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2636: -#line 15132 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15137 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->all_privileges= 1; Lex->grant= GLOBAL_ACLS; } -#line 39691 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39696 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2641: -#line 15150 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15155 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->which_columns = SELECT_ACL;} -#line 39697 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39702 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2642: -#line 15151 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15156 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39703 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39708 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2643: -#line 15153 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15158 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->which_columns = INSERT_ACL;} -#line 39709 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39714 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2644: -#line 15154 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15159 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39715 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39720 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2645: -#line 15156 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15161 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->which_columns = UPDATE_ACL; } -#line 39721 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39726 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2646: -#line 15157 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15162 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39727 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39732 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2647: -#line 15159 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15164 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->which_columns = REFERENCES_ACL;} -#line 39733 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39738 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2648: -#line 15160 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15165 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39739 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39744 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2649: -#line 15161 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15166 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= DELETE_ACL;} -#line 39745 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39750 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2650: -#line 15162 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15167 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39751 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39756 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2651: -#line 15163 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15168 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= INDEX_ACL;} -#line 39757 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39762 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2652: -#line 15164 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15169 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= ALTER_ACL;} -#line 39763 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39768 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2653: -#line 15165 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15170 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_ACL;} -#line 39769 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39774 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2654: -#line 15166 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15171 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= DROP_ACL;} -#line 39775 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39780 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2655: -#line 15167 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15172 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= EXECUTE_ACL;} -#line 39781 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39786 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2656: -#line 15168 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15173 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= RELOAD_ACL;} -#line 39787 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39792 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2657: -#line 15169 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15174 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= SHUTDOWN_ACL;} -#line 39793 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39798 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2658: -#line 15170 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15175 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= PROCESS_ACL;} -#line 39799 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39804 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2659: -#line 15171 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15176 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= FILE_ACL;} -#line 39805 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39810 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2660: -#line 15172 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15177 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= GRANT_ACL;} -#line 39811 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39816 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2661: -#line 15173 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15178 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= SHOW_DB_ACL;} -#line 39817 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39822 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2662: -#line 15174 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15179 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= SUPER_ACL;} -#line 39823 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39828 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2663: -#line 15175 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15180 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_TMP_ACL;} -#line 39829 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39834 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2664: -#line 15176 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15181 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= LOCK_TABLES_ACL; } -#line 39835 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39840 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2665: -#line 15177 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15182 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= REPL_SLAVE_ACL; } -#line 39841 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39846 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2666: -#line 15178 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15183 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= REPL_CLIENT_ACL; } -#line 39847 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39852 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2667: -#line 15179 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15184 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_VIEW_ACL; } -#line 39853 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39858 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2668: -#line 15180 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15185 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= SHOW_VIEW_ACL; } -#line 39859 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39864 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2669: -#line 15181 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15186 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_PROC_ACL; } -#line 39865 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39870 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2670: -#line 15182 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15187 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= ALTER_PROC_ACL; } -#line 39871 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39876 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2671: -#line 15183 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15188 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_USER_ACL; } -#line 39877 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39882 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2672: -#line 15184 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15189 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= EVENT_ACL;} -#line 39883 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39888 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2673: -#line 15185 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15190 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= TRIGGER_ACL; } -#line 39889 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39894 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2674: -#line 15186 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15191 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= CREATE_TABLESPACE_ACL; } -#line 39895 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39900 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2675: -#line 15190 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15195 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39901 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39906 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2676: -#line 15191 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15196 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 39907 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39912 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2679: -#line 15201 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15206 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (lex->x509_subject) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "SUBJECT")); lex->x509_subject=(yyvsp[0].lex_str).str; } -#line 39918 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39923 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2680: -#line 15208 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15213 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (lex->x509_issuer) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "ISSUER")); lex->x509_issuer=(yyvsp[0].lex_str).str; } -#line 39929 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39934 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2681: -#line 15215 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15220 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (lex->ssl_cipher) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CIPHER")); lex->ssl_cipher=(yyvsp[0].lex_str).str; } -#line 39940 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39945 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2682: -#line 15225 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15230 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; size_t dummy; @@ -39951,11 +39956,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); else if (lex->columns.elements) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } -#line 39955 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39960 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2683: -#line 15236 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15241 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->current_select->db = (yyvsp[-2].lex_str).str; @@ -39964,11 +39969,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); else if (lex->columns.elements) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } -#line 39968 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39973 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2684: -#line 15245 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15250 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->current_select->db = NULL; @@ -39977,11 +39982,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); else if (lex->columns.elements) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } -#line 39981 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39986 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2685: -#line 15254 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15259 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (!lex->current_select->add_table_to_list(thd, (yyvsp[0].table),NULL, @@ -39990,120 +39995,120 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (lex->grant == GLOBAL_ACLS) lex->grant = TABLE_ACLS & ~GRANT_ACL; } -#line 39994 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 39999 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2686: -#line 15266 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15271 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40003 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40008 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2687: -#line 15271 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15276 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40012 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40017 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2688: -#line 15279 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15284 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40021 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40026 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2689: -#line 15284 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15289 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40030 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40035 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2690: -#line 15292 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15297 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40039 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40044 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2691: -#line 15297 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15302 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->users_list.push_back((yyvsp[0].lex_user), thd->mem_root)) MYSQL_YYABORT; } -#line 40048 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40053 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2696: -#line 15308 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15313 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.lex_user)= (yyvsp[-3].lex_user); (yyvsp[-3].lex_user)->pwtext= (yyvsp[0].lex_str); if (Lex->sql_command == SQLCOM_REVOKE) MYSQL_YYABORT; } -#line 40059 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40064 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2697: -#line 15315 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15320 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.lex_user)= (yyvsp[-4].lex_user); (yyvsp[-4].lex_user)->pwhash= (yyvsp[0].lex_str); } -#line 40068 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40073 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2698: -#line 15320 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15325 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.lex_user)= (yyvsp[-3].lex_user); (yyvsp[-3].lex_user)->plugin= (yyvsp[0].lex_str); (yyvsp[-3].lex_user)->auth= empty_lex_str; } -#line 40078 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40083 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2699: -#line 15326 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15331 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.lex_user)= (yyvsp[-5].lex_user); (yyvsp[-5].lex_user)->plugin= (yyvsp[-2].lex_str); (yyvsp[-5].lex_user)->auth= (yyvsp[0].lex_str); } -#line 40088 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40093 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2700: -#line 15332 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15337 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.lex_user)= (yyvsp[0].lex_user); } -#line 40094 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40099 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2701: -#line 15337 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15342 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->grant |= lex->which_columns; } -#line 40103 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40108 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2705: -#line 15351 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15356 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { String *new_str= new (thd->mem_root) String((const char*) (yyvsp[0].lex_str).str,(yyvsp[0].lex_str).length,system_charset_info); if (new_str == NULL) @@ -40129,227 +40134,227 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->columns.push_back(col, thd->mem_root); } } -#line 40133 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40138 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2707: -#line 15381 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15386 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ssl_type=SSL_TYPE_SPECIFIED; } -#line 40141 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40146 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2708: -#line 15385 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15390 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ssl_type=SSL_TYPE_ANY; } -#line 40149 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40154 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2709: -#line 15389 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15394 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ssl_type=SSL_TYPE_X509; } -#line 40157 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40162 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2710: -#line 15393 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15398 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->ssl_type=SSL_TYPE_NONE; } -#line 40165 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40170 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2711: -#line 15399 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15404 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40171 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40176 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2713: -#line 15404 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15409 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40177 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40182 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2714: -#line 15405 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15410 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= GRANT_ACL;} -#line 40183 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40188 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2715: -#line 15409 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15414 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40189 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40194 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2716: -#line 15410 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15415 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40195 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40200 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2717: -#line 15414 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15419 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->grant |= GRANT_ACL;} -#line 40201 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40206 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2718: -#line 15416 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15421 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->mqh.questions=(yyvsp[0].ulong_num); lex->mqh.specified_limits|= USER_RESOURCES::QUERIES_PER_HOUR; } -#line 40211 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40216 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2719: -#line 15422 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15427 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->mqh.updates=(yyvsp[0].ulong_num); lex->mqh.specified_limits|= USER_RESOURCES::UPDATES_PER_HOUR; } -#line 40221 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40226 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2720: -#line 15428 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15433 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->mqh.conn_per_hour= (yyvsp[0].ulong_num); lex->mqh.specified_limits|= USER_RESOURCES::CONNECTIONS_PER_HOUR; } -#line 40231 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40236 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2721: -#line 15434 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15439 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->mqh.user_conn= (yyvsp[0].num); lex->mqh.specified_limits|= USER_RESOURCES::USER_CONNECTIONS; } -#line 40241 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40246 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2722: -#line 15440 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15445 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->mqh.max_statement_time= (yyvsp[0].item_num)->val_real(); lex->mqh.specified_limits|= USER_RESOURCES::MAX_STATEMENT_TIME; } -#line 40251 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40256 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2723: -#line 15449 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15454 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command = SQLCOM_BEGIN; lex->start_transaction_opt= 0; } -#line 40261 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40266 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2724: -#line 15454 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15459 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40267 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40272 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2725: -#line 15459 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15464 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command= SQLCOM_COMPOUND; Lex->sphead->set_stmt_end(thd); Lex->sphead->restore_thd_mem_root(thd); } -#line 40277 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40282 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2726: -#line 15467 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15472 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= 0; } -#line 40283 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40288 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2727: -#line 15468 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15473 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= 1; } -#line 40289 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40294 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2728: -#line 15472 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15477 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40295 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40300 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2729: -#line 15473 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15478 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40301 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40306 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2730: -#line 15478 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15483 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_UNKNOWN; } -#line 40307 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40312 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2731: -#line 15479 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15484 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_NO; } -#line 40313 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40318 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2732: -#line 15480 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15485 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_YES; } -#line 40319 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40324 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2733: -#line 15485 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15490 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_UNKNOWN; } -#line 40325 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40330 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2734: -#line 15486 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15491 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_YES; } -#line 40331 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40336 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2735: -#line 15487 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15492 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.m_yes_no_unk)= TVL_NO; } -#line 40337 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40342 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2736: -#line 15491 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15496 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40343 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40348 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2737: -#line 15492 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15497 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40349 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40354 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2738: -#line 15497 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15502 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command= SQLCOM_COMMIT; @@ -40358,11 +40363,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->tx_chain= (yyvsp[-1].m_yes_no_unk); lex->tx_release= (yyvsp[0].m_yes_no_unk); } -#line 40362 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40367 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2739: -#line 15509 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15514 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command= SQLCOM_ROLLBACK; @@ -40371,56 +40376,56 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->tx_chain= (yyvsp[-1].m_yes_no_unk); lex->tx_release= (yyvsp[0].m_yes_no_unk); } -#line 40375 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40380 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2740: -#line 15519 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15524 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT; lex->ident= (yyvsp[0].lex_str); } -#line 40385 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40390 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2741: -#line 15528 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15533 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command= SQLCOM_SAVEPOINT; lex->ident= (yyvsp[0].lex_str); } -#line 40395 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40400 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2742: -#line 15537 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15542 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; lex->sql_command= SQLCOM_RELEASE_SAVEPOINT; lex->ident= (yyvsp[0].lex_str); } -#line 40405 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40410 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2743: -#line 15550 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15555 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40411 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40416 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2745: -#line 15556 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15561 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (add_select_to_union_list(Lex, (bool)(yyvsp[0].num), TRUE)) MYSQL_YYABORT; } -#line 40420 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40425 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2746: -#line 15561 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15566 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* Remove from the name resolution context stack the context of the @@ -40428,29 +40433,29 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); */ Lex->pop_context(); } -#line 40432 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40437 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2748: -#line 15572 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15577 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= 1; } -#line 40438 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40443 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2749: -#line 15576 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15581 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= 0; } -#line 40444 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40449 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2750: -#line 15577 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15582 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)= 1; } -#line 40450 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40455 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2751: -#line 15581 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15586 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE); @@ -40464,80 +40469,80 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } thd->where= "global ORDER clause"; } -#line 40468 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40473 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2752: -#line 15595 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15600 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { thd->lex->current_select->no_table_names_allowed= 0; thd->where= ""; } -#line 40477 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40482 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2755: -#line 15607 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15612 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)=1; } -#line 40483 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40488 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2756: -#line 15608 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15613 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)=1; } -#line 40489 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40494 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2757: -#line 15609 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15614 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.num)=0; } -#line 40495 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40500 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2758: -#line 15615 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15620 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.select_lex)= Lex->current_select->master_unit()->first_select(); } -#line 40503 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40508 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2759: -#line 15620 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15625 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.select_lex)= Lex->current_select->master_unit()->first_select(); } -#line 40511 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40516 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2761: -#line 15629 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15634 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (add_select_to_union_list(Lex, (bool)(yyvsp[0].num), FALSE)) MYSQL_YYABORT; } -#line 40520 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40525 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2762: -#line 15634 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15639 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->pop_context(); (yyval.select_lex)= (yyvsp[-4].select_lex); } -#line 40529 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40534 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2763: -#line 15643 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15648 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { (yyval.select_lex)= (yyvsp[-1].select_lex); } -#line 40537 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40542 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2764: -#line 15649 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15654 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; if (!lex->expr_allows_subselect || @@ -40556,11 +40561,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); if (mysql_new_select(Lex, 1)) MYSQL_YYABORT; } -#line 40560 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40565 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2765: -#line 15670 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15675 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex=Lex; @@ -40583,17 +40588,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->current_select->select_n_having_items+= child->select_n_having_items; } -#line 40587 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40592 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2770: -#line 15705 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15710 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Select->options|= SELECT_STRAIGHT_JOIN; } -#line 40593 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40598 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2771: -#line 15707 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15712 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (check_simple_select()) MYSQL_YYABORT; @@ -40601,73 +40606,73 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); YYPS->m_mdl_type= MDL_SHARED_READ; Select->options|= SELECT_HIGH_PRIORITY; } -#line 40605 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40610 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2772: -#line 15714 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15719 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Select->options|= SELECT_DISTINCT; } -#line 40611 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40616 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2773: -#line 15715 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15720 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Select->options|= SELECT_SMALL_RESULT; } -#line 40617 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40622 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2774: -#line 15716 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15721 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Select->options|= SELECT_BIG_RESULT; } -#line 40623 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40628 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2775: -#line 15718 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15723 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (check_simple_select()) MYSQL_YYABORT; Select->options|= OPTION_BUFFER_RESULT; } -#line 40633 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40638 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2776: -#line 15724 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15729 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (check_simple_select()) MYSQL_YYABORT; Select->options|= OPTION_FOUND_ROWS; } -#line 40643 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40648 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2777: -#line 15729 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15734 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Select->options|= SELECT_ALL; } -#line 40649 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40654 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2778: -#line 15740 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15745 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40655 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40660 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2779: -#line 15742 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15747 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40661 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40666 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2780: -#line 15744 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15749 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40667 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40672 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2794: -#line 15777 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15782 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* We have to distinguish missing DEFINER-clause from case when @@ -40678,58 +40683,58 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); */ thd->lex->definer= 0; } -#line 40682 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40687 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2795: -#line 15791 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15796 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->definer= (yyvsp[0].lex_user); Lex->ssl_type= SSL_TYPE_NOT_SPECIFIED; Lex->ssl_cipher= Lex->x509_subject= Lex->x509_issuer= 0; bzero(&(Lex->mqh), sizeof(Lex->mqh)); } -#line 40693 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40698 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2796: -#line 15807 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15812 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; } -#line 40699 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40704 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2797: -#line 15809 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15814 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; } -#line 40705 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40710 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2798: -#line 15811 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15816 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; } -#line 40711 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40716 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2799: -#line 15816 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15821 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_suid= VIEW_SUID_DEFAULT; } -#line 40717 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40722 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2800: -#line 15818 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15823 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_suid= VIEW_SUID_DEFINER; } -#line 40723 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40728 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2801: -#line 15820 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15825 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_suid= VIEW_SUID_INVOKER; } -#line 40729 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40734 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2802: -#line 15825 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15830 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; if (lex->add_create_options_with_check((yyvsp[-1].object_ddl_options))) @@ -40743,37 +40748,37 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB; } -#line 40747 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40752 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2804: -#line 15843 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15848 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 40753 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40758 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2806: -#line 15849 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15854 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->view_list.push_back((LEX_STRING*) thd->memdup(&(yyvsp[0].lex_str), sizeof(LEX_STRING)), thd->mem_root); } -#line 40763 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40768 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2807: -#line 15855 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15860 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->view_list.push_back((LEX_STRING*) thd->memdup(&(yyvsp[0].lex_str), sizeof(LEX_STRING)), thd->mem_root); } -#line 40773 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40778 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2808: -#line 15863 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15868 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->parsing_options.allows_variable= FALSE; @@ -40782,11 +40787,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->parsing_options.allows_derived= FALSE; lex->create_view_select.str= (char *) YYLIP->get_cpp_ptr(); } -#line 40786 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40791 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2809: -#line 15872 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15877 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str; @@ -40799,60 +40804,60 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->parsing_options.allows_select_procedure= TRUE; lex->parsing_options.allows_derived= TRUE; } -#line 40803 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40808 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2812: -#line 15893 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15898 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_check= VIEW_CHECK_NONE; } -#line 40809 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40814 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2813: -#line 15895 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15900 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_check= VIEW_CHECK_CASCADED; } -#line 40815 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40820 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2814: -#line 15897 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15902 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_check= VIEW_CHECK_CASCADED; } -#line 40821 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40826 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2815: -#line 15899 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15904 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->create_view_check= VIEW_CHECK_LOCAL; } -#line 40827 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40832 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2816: -#line 15912 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15917 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->add_create_options_with_check((yyvsp[0].object_ddl_options))) MYSQL_YYABORT; } -#line 40836 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40841 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2817: -#line 15921 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15926 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $10 */ Lex->raw_trg_on_table_name_begin= YYLIP->get_tok_start(); } -#line 40844 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40849 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2818: -#line 15927 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15932 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $14 */ Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start(); } -#line 40852 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40857 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2819: -#line 15932 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15937 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $17 */ LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -40870,11 +40875,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sphead->set_body_start(thd, lip->get_cpp_ptr()); } -#line 40874 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40879 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2820: -#line 15950 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15955 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $19 */ LEX *lex= Lex; sp_head *sp= lex->sphead; @@ -40898,23 +40903,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MDL_SHARED_NO_WRITE)) MYSQL_YYABORT; } -#line 40902 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40907 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2821: -#line 15982 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15987 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { thd->lex->udf.type= UDFTYPE_AGGREGATE; } -#line 40908 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40913 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2822: -#line 15983 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15988 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { thd->lex->udf.type= UDFTYPE_FUNCTION; } -#line 40914 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40919 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2823: -#line 15989 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 15994 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; if (lex->add_create_options_with_check((yyvsp[-5].object_ddl_options))) @@ -40926,11 +40931,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->udf.returns= (Item_result) (yyvsp[-2].num); lex->udf.dl= (yyvsp[0].lex_str).str; } -#line 40930 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40935 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2824: -#line 16007 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16012 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $5 */ LEX *lex= Lex; Lex_input_stream *lip= YYLIP; @@ -40950,50 +40955,50 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); tmp_param_begin++; lex->sphead->m_param_begin= tmp_param_begin; } -#line 40954 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40959 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2825: -#line 16028 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16033 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $8 */ Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start(); } -#line 40962 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40967 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2826: -#line 16032 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16037 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $10 */ LEX *lex= Lex; lex->init_last_field(&lex->sphead->m_return_field_def, NULL, thd->variables.collation_database); } -#line 40972 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40977 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2827: -#line 16038 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16043 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $12 */ if (Lex->sphead->fill_field_definition(thd, Lex, (yyvsp[0].field_type), Lex->last_field)) MYSQL_YYABORT; } -#line 40982 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40987 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2828: -#line 16044 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16049 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { /* $14 */ LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } -#line 40993 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 40998 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2829: -#line 16051 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16056 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= thd->lex; sp_head *sp= lex->sphead; @@ -41042,11 +41047,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } sp->restore_thd_mem_root(thd); } -#line 41046 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41051 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2830: -#line 16103 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16108 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { if (Lex->add_create_options_with_check((yyvsp[-1].object_ddl_options))) MYSQL_YYABORT; @@ -41058,11 +41063,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); MYSQL_YYABORT; Lex->spname= (yyvsp[0].spname); } -#line 41062 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41067 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2831: -#line 16115 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16120 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { const char* tmp_param_begin; @@ -41070,27 +41075,27 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); tmp_param_begin++; Lex->sphead->m_param_begin= tmp_param_begin; } -#line 41074 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41079 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2832: -#line 16124 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16129 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start(); } -#line 41082 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41087 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2833: -#line 16128 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16133 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } -#line 41090 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41095 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2834: -#line 16132 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16137 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; sp_head *sp= lex->sphead; @@ -41099,209 +41104,209 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); lex->sql_command= SQLCOM_CREATE_PROCEDURE; sp->restore_thd_mem_root(thd); } -#line 41103 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41108 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2835: -#line 16146 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16151 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_START; } -#line 41111 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41116 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2836: -#line 16150 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16155 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_END; } -#line 41119 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41124 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2837: -#line 16154 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16159 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_PREPARE; } -#line 41127 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41132 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2838: -#line 16158 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16163 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_COMMIT; } -#line 41135 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41140 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2839: -#line 16162 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16167 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_ROLLBACK; } -#line 41143 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41148 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2840: -#line 16166 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16171 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->sql_command = SQLCOM_XA_RECOVER; } -#line 41151 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41156 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2841: -#line 16173 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16178 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { MYSQL_YYABORT_UNLESS((yyvsp[0].string)->length() <= MAXGTRIDSIZE); if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set(1L, (yyvsp[0].string)->ptr(), (yyvsp[0].string)->length(), 0, 0); } -#line 41162 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41167 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2842: -#line 16180 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16185 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { MYSQL_YYABORT_UNLESS((yyvsp[-2].string)->length() <= MAXGTRIDSIZE && (yyvsp[0].string)->length() <= MAXBQUALSIZE); if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set(1L, (yyvsp[-2].string)->ptr(), (yyvsp[-2].string)->length(), (yyvsp[0].string)->ptr(), (yyvsp[0].string)->length()); } -#line 41173 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41178 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2843: -#line 16187 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16192 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { MYSQL_YYABORT_UNLESS((yyvsp[-4].string)->length() <= MAXGTRIDSIZE && (yyvsp[-2].string)->length() <= MAXBQUALSIZE); if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set((yyvsp[0].ulong_num), (yyvsp[-4].string)->ptr(), (yyvsp[-4].string)->length(), (yyvsp[-2].string)->ptr(), (yyvsp[-2].string)->length()); } -#line 41184 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41189 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2844: -#line 16196 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16201 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 41190 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41195 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2845: -#line 16197 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16202 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 41196 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41201 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2846: -#line 16201 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16206 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_NONE; } -#line 41202 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41207 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2847: -#line 16202 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16207 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_JOIN; } -#line 41208 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41213 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2848: -#line 16203 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16208 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_RESUME; } -#line 41214 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41219 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2849: -#line 16207 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16212 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_NONE; } -#line 41220 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41225 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2850: -#line 16208 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16213 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_ONE_PHASE; } -#line 41226 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41231 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2851: -#line 16213 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16218 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_NONE; } -#line 41232 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41237 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2852: -#line 16215 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16220 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_SUSPEND; } -#line 41238 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41243 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2854: -#line 16220 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16225 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ {} -#line 41244 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41249 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2855: -#line 16221 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16226 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { Lex->xa_opt=XA_FOR_MIGRATE; } -#line 41250 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41255 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2856: -#line 16226 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16231 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_INSTALL_PLUGIN; lex->comment= (yyvsp[-2].lex_str); lex->ident= (yyvsp[0].lex_str); } -#line 41261 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41266 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2857: -#line 16233 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16238 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_INSTALL_PLUGIN; lex->comment= null_lex_str; lex->ident= (yyvsp[0].lex_str); } -#line 41272 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41277 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2858: -#line 16243 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16248 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_UNINSTALL_PLUGIN; lex->comment= (yyvsp[0].lex_str); } -#line 41282 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41287 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2859: -#line 16249 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16254 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { LEX *lex= Lex; lex->sql_command= SQLCOM_UNINSTALL_PLUGIN; lex->comment= null_lex_str; lex->ident= (yyvsp[0].lex_str); } -#line 41293 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41298 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; case 2860: -#line 16260 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ +#line 16265 "/home/buildbot/git/sql/sql_yacc.yy" /* yacc.c:1646 */ { YYERROR; } -#line 41301 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41306 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ break; -#line 41305 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ +#line 41310 "/home/buildbot/git/mkdist/sql/sql_yacc.cc" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1d380ce0c6ba76a4902218632007bd0c3c453894..fcfc63439cb76e8fff8ac2c0e4f45c9b5643d3ff 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -14503,6 +14503,11 @@ option_value_no_option_type: | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default { struct sys_var_with_base tmp= $4; + if (tmp.var == trg_new_row_fake_var) + { + my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), "NEW"); + MYSQL_YYABORT; + } /* Lookup if necessary: must be a system variable. */ if (tmp.var == NULL) { diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 303633939c33d5afb6473b492c17387b3063febc..5470acc789209da0c419f4f6f13e1db541f3ee8d 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2015, Oracle and/or its affiliates. - Copyright (c) 2012, 2015, MariaDB + Copyright (c) 2012, 2018, MariaDB 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 @@ -428,7 +428,7 @@ error_if_in_trans_or_substatement(THD *thd, int in_substatement_error, return false; } -static bool check_has_super(sys_var *self, THD *thd, set_var *var) +bool check_has_super(sys_var *self, THD *thd, set_var *var) { DBUG_ASSERT(self->scope() != sys_var::GLOBAL);// don't abuse check_has_super() #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -1387,7 +1387,7 @@ static bool fix_max_connections(sys_var *self, THD *thd, enum_var_type type) static Sys_var_ulong Sys_max_connections( "max_connections", "The number of simultaneous clients allowed", PARSED_EARLY GLOBAL_VAR(max_connections), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 100000), + VALID_RANGE(10, 100000), DEFAULT(MAX_CONNECTIONS_DEFAULT), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections)); @@ -2111,11 +2111,11 @@ static Sys_var_ulong Sys_max_long_data_size( BLOCK_SIZE(1)); static PolyLock_mutex PLock_prepared_stmt_count(&LOCK_prepared_stmt_count); -static Sys_var_ulong Sys_max_prepared_stmt_count( +static Sys_var_uint Sys_max_prepared_stmt_count( "max_prepared_stmt_count", "Maximum number of prepared statements in the server", GLOBAL_VAR(max_prepared_stmt_count), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, 1024*1024), DEFAULT(16382), BLOCK_SIZE(1), + VALID_RANGE(0, UINT_MAX32), DEFAULT(16382), BLOCK_SIZE(1), &PLock_prepared_stmt_count); static Sys_var_ulong Sys_max_sort_length( @@ -3192,7 +3192,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type) static Sys_var_ulong Sys_table_cache_size( "table_open_cache", "The number of cached open tables", GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(1, 1024*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT), + VALID_RANGE(10, 1024*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_table_open_cache)); @@ -4967,6 +4967,14 @@ static Sys_var_mybool Sys_wsrep_desync ( ON_CHECK(wsrep_desync_check), ON_UPDATE(wsrep_desync_update)); +static const char *wsrep_reject_queries_names[]= { "NONE", "ALL", "ALL_KILL", NullS }; +static Sys_var_enum Sys_wsrep_reject_queries( + "wsrep_reject_queries", "Variable to set to reject queries", + GLOBAL_VAR(wsrep_reject_queries), CMD_LINE(OPT_ARG), + wsrep_reject_queries_names, DEFAULT(WSREP_REJECT_NONE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + ON_UPDATE(wsrep_reject_queries_update)); + static const char *wsrep_binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", "NONE", NullS}; static Sys_var_enum Sys_wsrep_forced_binlog_format( diff --git a/sql/table.cc b/sql/table.cc index ea0bc8f5c95e78dc0c190773f2ff507e947518ef..4407d631db80a5153a2d7b3c54794514ce270038 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. + Copyright (c) 2008, 2018, MariaDB 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 @@ -2233,6 +2233,9 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, goto ret; thd->lex->create_info.db_type= hton; +#ifdef WITH_PARTITION_STORAGE_ENGINE + thd->work_part_info= 0; // For partitioning +#endif if (tabledef_version.str) thd->lex->create_info.tabledef_version= tabledef_version; @@ -3734,7 +3737,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) /* Whether the table definition has already been validated. */ if (table->s->table_field_def_cache == table_def) - DBUG_RETURN(FALSE); + goto end; if (table->s->fields != table_def->count) { @@ -3898,6 +3901,16 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) if (! error) table->s->table_field_def_cache= table_def; +end: + + if (has_keys && !error && !table->key_info) + { + report_error(0, "Incorrect definition of table %s.%s: " + "indexes are missing", + table->s->db.str, table->alias.c_ptr()); + error= TRUE; + } + DBUG_RETURN(error); } @@ -5415,6 +5428,8 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, Item_direct_view_ref(thd, &view->view->select_lex.context, field_ref, view->alias, name, view)); + if (!item) + return NULL; /* Force creation of nullable item for the result tmp table for outer joined views/derived tables. @@ -7345,7 +7360,15 @@ int TABLE_LIST::fetch_number_of_rows() { int error= 0; if (jtbm_subselect) + { + if (jtbm_subselect->is_jtbm_merged) + { + table->file->stats.records= jtbm_subselect->jtbm_record_count; + set_if_bigger(table->file->stats.records, 2); + table->used_stat_records= table->file->stats.records; + } return 0; + } if (is_materialized_derived() && !fill_me) { diff --git a/sql/table.h b/sql/table.h index 5abb99cd0c78a468c5b35c028ca32597dc299e9f..bf9b55089ef72c1c1ff5fa391a6894ba5b24762e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1,7 +1,7 @@ #ifndef TABLE_INCLUDED #define TABLE_INCLUDED -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. + Copyright (c) 2009, 2018, MariaDB 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 @@ -513,10 +513,11 @@ typedef struct st_table_field_def class Table_check_intact { protected: + bool has_keys; virtual void report_error(uint code, const char *fmt, ...)= 0; public: - Table_check_intact() {} + Table_check_intact(bool keys= false) : has_keys(keys) {} virtual ~Table_check_intact() {} /** Checks whether a table is intact. */ @@ -531,6 +532,8 @@ class Table_check_intact_log_error : public Table_check_intact { protected: void report_error(uint, const char *fmt, ...); +public: + Table_check_intact_log_error() : Table_check_intact(true) {} }; @@ -2305,6 +2308,7 @@ struct TABLE_LIST DBUG_PRINT("enter", ("Alias: '%s' Unit: %p", (alias ? alias : ""), get_unit())); + derived= get_unit(); derived_type= ((derived_type & (derived ? DTYPE_MASK : DTYPE_VIEW)) | DTYPE_TABLE | DTYPE_MATERIALIZE); set_check_materialized(); diff --git a/sql/tztime.cc b/sql/tztime.cc index bed5f416f13028ef37b0cf614caf13add47fcacf..7df2ad7d0e86dd620cabeb2cdb0e442beb19dccc 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2689,9 +2689,7 @@ main(int argc, char **argv) char **default_argv; MY_INIT(argv[0]); - if (load_defaults("my",load_default_groups,&argc,&argv)) - exit(1); - + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; if ((handle_options(&argc, &argv, my_long_options, get_one_option))) diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index e5c95780df510e5ee47f37ee502dc8eb4d23a3c2..723804c76db9a340130955507f111560f9c77637 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -98,11 +98,11 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, DBUG_RETURN(WSREP_CB_FAILURE); } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_query_state= QUERY_EXEC; if (thd->wsrep_conflict_state!= REPLAYING) thd->wsrep_conflict_state= NO_CONFLICT; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); if (!buf_len) WSREP_DEBUG("empty rbr buffer to apply: %lld", (long long) wsrep_thd_trx_seqno(thd)); @@ -197,9 +197,9 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, } error: - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_query_state= QUERY_IDLE; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); assert(thd->wsrep_exec_mode== REPL_RECV); diff --git a/sql/wsrep_check_opts.cc b/sql/wsrep_check_opts.cc index 690c1a4b2a45eb8dbaf6804bbbbc91312bb67a03..28bd3a4492b280c55c2b17bdd0e1db91b08aaf9f 100644 --- a/sql/wsrep_check_opts.cc +++ b/sql/wsrep_check_opts.cc @@ -51,7 +51,7 @@ int wsrep_check_opts() (!strcasecmp(my_bind_addr_str, "127.0.0.1") || !strcasecmp(my_bind_addr_str, "localhost"))) { - WSREP_ERROR("wsrep_sst_method is set to 'mysqldump' yet " + WSREP_WARN("wsrep_sst_method is set to 'mysqldump' yet " "mysqld bind_address is set to '%s', which makes it " "impossible to receive state transfer from another " "node, since mysqld won't accept such connections. " @@ -59,7 +59,6 @@ int wsrep_check_opts() "set bind_address to allow mysql client connections " "from other cluster members (e.g. 0.0.0.0).", my_bind_addr_str); - return 1; } } else diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 75c1526cb155d9d213f03e71278dabd717fa2b2b..e5c754a9d41f9a9d7aa10c24713221ef0a00d295 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -117,10 +117,10 @@ void wsrep_post_commit(THD* thd, bool all) switch (thd->wsrep_exec_mode) { - case LOCAL_COMMIT: + case LOCAL_COMMIT: { DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); - if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + if (wsrep && wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("set committed fail")); WSREP_WARN("set committed fail: %llu %d", @@ -129,18 +129,30 @@ void wsrep_post_commit(THD* thd, bool all) wsrep_cleanup_transaction(thd); break; } - case LOCAL_STATE: - { - /* - Non-InnoDB statements may have populated events in stmt cache => cleanup - */ - WSREP_DEBUG("cleanup transaction for LOCAL_STATE: %s", thd->query()); - wsrep_cleanup_transaction(thd); - break; - } - default: break; + case LOCAL_STATE: + { + /* non-InnoDB statements may have populated events in stmt cache + => cleanup + */ + WSREP_DEBUG("cleanup transaction for LOCAL_STATE"); + /* + Run post-rollback hook to clean up in the case if + some keys were populated for the transaction in provider + but during commit time there was no write set to replicate. + This may happen when client sets the SAVEPOINT and immediately + rolls back to savepoint after first operation. + */ + if (all && thd->wsrep_conflict_state != MUST_REPLAY && + wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + { + WSREP_WARN("post_rollback fail: %llu %d", + (long long)thd->thread_id, thd->get_stmt_da()->status()); + } + wsrep_cleanup_transaction(thd); + break; + } + default: break; } - } /* @@ -238,12 +250,12 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all) DBUG_RETURN(0); } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); switch (thd->wsrep_exec_mode) { case TOTAL_ORDER: case REPL_RECV: - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); WSREP_DEBUG("Avoiding wsrep rollback for failed DDL: %s", thd->query()); DBUG_RETURN(0); default: break; @@ -252,7 +264,7 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all) if ((all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && (thd->variables.wsrep_on && thd->wsrep_conflict_state != MUST_REPLAY)) { - if (wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + if (wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("setting rollback fail")); WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", @@ -261,7 +273,7 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all) } wsrep_cleanup_transaction(thd); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(0); } @@ -274,7 +286,7 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all) DBUG_RETURN(0); } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if ((all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && (thd->variables.wsrep_on && thd->wsrep_conflict_state != MUST_REPLAY)) { @@ -294,7 +306,7 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all) possible changes to clean state. */ if (WSREP_PROVIDER_EXISTS) { - if (wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + if (wsrep && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("setting rollback fail")); WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", @@ -305,7 +317,7 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all) wsrep_cleanup_transaction(thd); } } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(0); } @@ -333,20 +345,20 @@ wsrep_run_wsrep_commit(THD *thd, bool all) if (thd->wsrep_exec_mode == REPL_RECV) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == MUST_ABORT) { if (wsrep_debug) WSREP_INFO("WSREP: must abort for BF"); DBUG_PRINT("wsrep", ("BF apply commit fail")); thd->wsrep_conflict_state = NO_CONFLICT; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); // // TODO: test all calls of the rollback. // rollback must happen automagically innobase_rollback(hton, thd, 1); // DBUG_RETURN(WSREP_TRX_ERROR); } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } if (thd->wsrep_exec_mode != LOCAL_STATE) DBUG_RETURN(WSREP_TRX_OK); @@ -358,11 +370,11 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_PRINT("wsrep", ("replicating commit")); - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == MUST_ABORT) { DBUG_PRINT("wsrep", ("replicate commit fail")); thd->wsrep_conflict_state = ABORTED; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); if (wsrep_debug) { WSREP_INFO("innobase_commit, abort %s", (thd->query()) ? thd->query() : "void"); @@ -379,7 +391,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) { mysql_mutex_unlock(&LOCK_wsrep_replaying); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); mysql_mutex_lock(&thd->mysys_var->mutex); thd_proc_info(thd, "wsrep waiting on replaying"); @@ -407,7 +419,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) thd->mysys_var->current_cond= 0; mysql_mutex_unlock(&thd->mysys_var->mutex); - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); mysql_mutex_lock(&LOCK_wsrep_replaying); } mysql_mutex_unlock(&LOCK_wsrep_replaying); @@ -415,14 +427,14 @@ wsrep_run_wsrep_commit(THD *thd, bool all) if (thd->wsrep_conflict_state == MUST_ABORT) { DBUG_PRINT("wsrep", ("replicate commit fail")); thd->wsrep_conflict_state = ABORTED; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); WSREP_DEBUG("innobase_commit abort after replaying wait %s", (thd->query()) ? thd->query() : "void"); DBUG_RETURN(WSREP_TRX_CERT_FAIL); } thd->wsrep_query_state = QUERY_COMMITTING; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); cache = get_trans_log(thd); rcode = 0; @@ -471,7 +483,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) } else if (!rcode) { - if (WSREP_OK == rcode) + if (WSREP_OK == rcode && wsrep) rcode = wsrep->pre_commit(wsrep, (wsrep_conn_id_t)thd->thread_id, &thd->wsrep_ws_handle, @@ -487,10 +499,10 @@ wsrep_run_wsrep_commit(THD *thd, bool all) } else if (rcode == WSREP_BF_ABORT) { WSREP_DEBUG("thd %lu seqno %lld BF aborted by provider, will replay", thd->thread_id, (long long)thd->wsrep_trx_meta.gtid.seqno); - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_conflict_state = MUST_REPLAY; DBUG_ASSERT(wsrep_thd_trx_seqno(thd) > 0); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); mysql_mutex_lock(&LOCK_wsrep_replaying); wsrep_replaying++; WSREP_DEBUG("replaying increased: %d, thd: %lu", @@ -504,7 +516,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_RETURN(WSREP_TRX_ERROR); } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); DEBUG_SYNC(thd, "wsrep_after_replication"); @@ -558,26 +570,26 @@ wsrep_run_wsrep_commit(THD *thd, bool all) WSREP_LOG_CONFLICT(NULL, thd, FALSE); } } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_CERT_FAIL); case WSREP_SIZE_EXCEEDED: WSREP_ERROR("transaction size exceeded"); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_SIZE_EXCEEDED); case WSREP_CONN_FAIL: WSREP_ERROR("connection failure"); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_ERROR); default: WSREP_ERROR("unknown connection failure"); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_ERROR); } thd->wsrep_query_state= QUERY_EXEC; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_OK); } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 285bb520b87d4ed676022407207fe7632d4c1213..b127d3a8f002a0da636fd92c5fd32667e458ef10 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -13,6 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include // SHOW_MY_BOOL #include #include #include @@ -128,7 +129,7 @@ ulong wsrep_running_threads = 0; // # of currently running wsrep threads ulong my_bind_addr; #ifdef HAVE_PSI_INTERFACE -PSI_mutex_key key_LOCK_wsrep_rollback, key_LOCK_wsrep_thd, +PSI_mutex_key key_LOCK_wsrep_rollback, key_LOCK_wsrep_replaying, key_LOCK_wsrep_ready, key_LOCK_wsrep_sst, key_LOCK_wsrep_sst_thread, key_LOCK_wsrep_sst_init, key_LOCK_wsrep_slave_threads, key_LOCK_wsrep_desync, @@ -148,7 +149,6 @@ static PSI_mutex_info wsrep_mutexes[]= { &key_LOCK_wsrep_sst_init, "LOCK_wsrep_sst_init", PSI_FLAG_GLOBAL}, { &key_LOCK_wsrep_sst, "LOCK_wsrep_sst", PSI_FLAG_GLOBAL}, { &key_LOCK_wsrep_rollback, "LOCK_wsrep_rollback", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_thd, "THD::LOCK_wsrep_thd", 0}, { &key_LOCK_wsrep_replaying, "LOCK_wsrep_replaying", PSI_FLAG_GLOBAL}, { &key_LOCK_wsrep_slave_threads, "LOCK_wsrep_slave_threads", PSI_FLAG_GLOBAL}, { &key_LOCK_wsrep_desync, "LOCK_wsrep_desync", PSI_FLAG_GLOBAL}, @@ -289,8 +289,7 @@ wsrep_view_handler_cb (void* app_ctx, if (memcmp(&cluster_uuid, &view->state_id.uuid, sizeof(wsrep_uuid_t))) { - memcpy((wsrep_uuid_t*)&cluster_uuid, &view->state_id.uuid, - sizeof(cluster_uuid)); + memcpy(&cluster_uuid, &view->state_id.uuid, sizeof(cluster_uuid)); wsrep_uuid_print (&cluster_uuid, cluster_uuid_str, sizeof(cluster_uuid_str)); @@ -336,7 +335,7 @@ wsrep_view_handler_cb (void* app_ctx, // version change if (view->proto_ver != wsrep_protocol_version) { - my_bool wsrep_ready_saved= wsrep_ready; + my_bool wsrep_ready_saved= wsrep_ready_get(); wsrep_ready_set(FALSE); WSREP_INFO("closing client connections for " "protocol change %ld -> %d", @@ -369,7 +368,7 @@ wsrep_view_handler_cb (void* app_ctx, if (!wsrep_before_SE()) { WSREP_DEBUG("[debug]: closing client connections for PRIM"); - wsrep_close_client_connections(TRUE); + wsrep_close_client_connections(FALSE); } ssize_t const req_len= wsrep_sst_prepare (sst_req); @@ -451,16 +450,34 @@ wsrep_view_handler_cb (void* app_ctx, return WSREP_CB_SUCCESS; } -void wsrep_ready_set (my_bool x) +my_bool wsrep_ready_set (my_bool x) { WSREP_DEBUG("Setting wsrep_ready to %d", x); if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort(); - if (wsrep_ready != x) + my_bool ret= (wsrep_ready != x); + if (ret) { wsrep_ready= x; mysql_cond_signal (&COND_wsrep_ready); } mysql_mutex_unlock (&LOCK_wsrep_ready); + return ret; +} + +my_bool wsrep_ready_get (void) +{ + if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort(); + my_bool ret= wsrep_ready; + mysql_mutex_unlock (&LOCK_wsrep_ready); + return ret; +} + +int wsrep_show_ready(THD *thd, SHOW_VAR *var, char *buff) +{ + var->type= SHOW_MY_BOOL; + var->value= buff; + *((my_bool *)buff)= wsrep_ready_get(); + return 0; } // Wait until wsrep has reached ready state @@ -479,17 +496,8 @@ void wsrep_ready_wait () static void wsrep_synced_cb(void* app_ctx) { WSREP_INFO("Synchronized with group, ready for connections"); - bool signal_main= false; - if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort(); - if (!wsrep_ready) - { - wsrep_ready= TRUE; - mysql_cond_signal (&COND_wsrep_ready); - signal_main= true; - - } + my_bool signal_main= wsrep_ready_set(TRUE); wsrep_config_state.set(WSREP_MEMBER_SYNCED); - mysql_mutex_unlock (&LOCK_wsrep_ready); if (signal_main) { @@ -961,6 +969,8 @@ bool wsrep_must_sync_wait (THD* thd, uint mask) { return (thd->variables.wsrep_sync_wait & mask) && thd->variables.wsrep_on && + !(thd->variables.wsrep_dirty_reads && + !is_update_query(thd->lex->sql_command)) && !thd->in_active_multi_stmt_transaction() && thd->wsrep_conflict_state != REPLAYING && thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; @@ -1008,17 +1018,7 @@ bool wsrep_sync_wait (THD* thd, uint mask) return false; } -/* - * Helpers to deal with TOI key arrays - */ -typedef struct wsrep_key_arr -{ - wsrep_key_t* keys; - size_t keys_len; -} wsrep_key_arr_t; - - -static void wsrep_keys_free(wsrep_key_arr_t* key_arr) +void wsrep_keys_free(wsrep_key_arr_t* key_arr) { for (size_t i= 0; i < key_arr->keys_len; ++i) { @@ -1083,11 +1083,11 @@ static bool wsrep_prepare_key_for_isolation(const char* db, } /* Prepare key list from db/table and table_list */ -static bool wsrep_prepare_keys_for_isolation(THD* thd, - const char* db, - const char* table, - const TABLE_LIST* table_list, - wsrep_key_arr_t* ka) +bool wsrep_prepare_keys_for_isolation(THD* thd, + const char* db, + const char* table, + const TABLE_LIST* table_list, + wsrep_key_arr_t* ka) { ka->keys= 0; ka->keys_len= 0; @@ -1659,7 +1659,7 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, if (thd->wsrep_exec_mode == REPL_RECV) return 0; - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); if (thd->wsrep_conflict_state == MUST_ABORT) { @@ -1667,10 +1667,10 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, thd->thread_id, (thd->db ? thd->db : "(null)"), thd->query()); - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); return WSREP_TRX_FAIL; } - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_ASSERT(thd->wsrep_exec_mode == LOCAL_STATE); DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno == WSREP_SEQNO_UNDEFINED); @@ -1786,23 +1786,23 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, const char* schema= key->db_name(); int schema_len= key->db_name_length(); - mysql_mutex_lock(&request_thd->LOCK_wsrep_thd); + mysql_mutex_lock(&request_thd->LOCK_thd_data); if (request_thd->wsrep_exec_mode == TOTAL_ORDER || request_thd->wsrep_exec_mode == REPL_RECV) { - mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&request_thd->LOCK_thd_data); WSREP_MDL_LOG(DEBUG, "MDL conflict ", schema, schema_len, request_thd, granted_thd); ticket->wsrep_report(wsrep_debug); - mysql_mutex_lock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_lock(&granted_thd->LOCK_thd_data); if (granted_thd->wsrep_exec_mode == TOTAL_ORDER || granted_thd->wsrep_exec_mode == REPL_RECV) { WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", schema, schema_len, request_thd, granted_thd); ticket->wsrep_report(true); - mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&granted_thd->LOCK_thd_data); ret = TRUE; } else if (granted_thd->lex->sql_command == SQLCOM_FLUSH || @@ -1810,14 +1810,14 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, { WSREP_DEBUG("BF thread waiting for FLUSH"); ticket->wsrep_report(wsrep_debug); - mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&granted_thd->LOCK_thd_data); ret = FALSE; } else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE) { - WSREP_DEBUG("DROP caused BF abort"); + WSREP_DEBUG("DROP caused BF abort, conf %d", granted_thd->wsrep_conflict_state); ticket->wsrep_report(wsrep_debug); - mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&granted_thd->LOCK_thd_data); wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1); ret = FALSE; } @@ -1825,7 +1825,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, { WSREP_DEBUG("MDL granted, but committing thd abort scheduled"); ticket->wsrep_report(wsrep_debug); - mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&granted_thd->LOCK_thd_data); wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1); ret = FALSE; } @@ -1834,14 +1834,14 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", schema, schema_len, request_thd, granted_thd); ticket->wsrep_report(wsrep_debug); - mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&granted_thd->LOCK_thd_data); wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1); ret = FALSE; } } else { - mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&request_thd->LOCK_thd_data); } return ret; } @@ -2006,9 +2006,9 @@ static inline bool is_replaying_connection(THD *thd) { bool ret; - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); ret= (thd->wsrep_conflict_state == REPLAYING) ? true : false; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); return ret; } @@ -2018,9 +2018,9 @@ static inline bool is_committing_connection(THD *thd) { bool ret; - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); ret= (thd->wsrep_query_state == QUERY_COMMITTING) ? true : false; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); return ret; } @@ -2336,7 +2336,7 @@ extern "C" void wsrep_thd_set_query_state( void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state) { - thd->wsrep_conflict_state= state; + if (WSREP(thd)) thd->wsrep_conflict_state= state; } @@ -2403,13 +2403,13 @@ wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd) void wsrep_thd_LOCK(THD *thd) { - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); } void wsrep_thd_UNLOCK(THD *thd) { - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index fd68fab991c278b6c8d874a3b76366534fc515ed..272e4ac4984b3211e5a9f00dec1c02feb1e0f29e 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -80,6 +80,7 @@ extern const char* wsrep_notify_cmd; extern long wsrep_max_protocol_version; extern ulong wsrep_forced_binlog_format; extern my_bool wsrep_desync; +extern ulong wsrep_reject_queries; extern my_bool wsrep_replicate_myisam; extern ulong wsrep_mysql_replication_bundle; extern my_bool wsrep_restart_slave; @@ -92,6 +93,12 @@ extern bool wsrep_gtid_mode; extern uint32 wsrep_gtid_domain_id; extern bool wsrep_dirty_reads; +enum enum_wsrep_reject_types { + WSREP_REJECT_NONE, /* nothing rejected */ + WSREP_REJECT_ALL, /* reject all queries, with UNKNOWN_COMMAND error */ + WSREP_REJECT_ALL_KILL /* kill existing connections and reject all queries*/ +}; + enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU, @@ -227,6 +234,7 @@ extern wsrep_seqno_t wsrep_locked_seqno; #define WSREP_QUERY(thd) (thd->query()) +extern my_bool wsrep_ready_get(); extern void wsrep_ready_wait(); class Ha_trx_info; @@ -265,8 +273,6 @@ extern my_bool wsrep_preordered_opt; extern handlerton *wsrep_hton; #ifdef HAVE_PSI_INTERFACE -extern PSI_mutex_key key_LOCK_wsrep_thd; -extern PSI_cond_key key_COND_wsrep_thd; extern PSI_mutex_key key_LOCK_wsrep_ready; extern PSI_mutex_key key_COND_wsrep_ready; extern PSI_mutex_key key_LOCK_wsrep_sst; @@ -321,6 +327,18 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, bool wsrep_node_is_donor(); bool wsrep_node_is_synced(); +typedef struct wsrep_key_arr +{ + wsrep_key_t* keys; + size_t keys_len; +} wsrep_key_arr_t; +bool wsrep_prepare_keys_for_isolation(THD* thd, + const char* db, + const char* table, + const TABLE_LIST* table_list, + wsrep_key_arr_t* ka); +void wsrep_keys_free(wsrep_key_arr_t* key_arr); + #else /* WITH_WSREP */ #define WSREP(T) (0) @@ -350,6 +368,5 @@ bool wsrep_node_is_synced(); #define wsrep_thr_init() do {} while(0) #define wsrep_thr_deinit() do {} while(0) #define wsrep_running_threads (0) - #endif /* WITH_WSREP */ #endif /* WSREP_MYSQLD_H */ diff --git a/sql/wsrep_priv.h b/sql/wsrep_priv.h index 119f17c2afc1ebbca52bc5475138b96d27176d30..b00bfda16fab8e7287d6aef0b1d556f3379752fa 100644 --- a/sql/wsrep_priv.h +++ b/sql/wsrep_priv.h @@ -26,7 +26,7 @@ #include #include -void wsrep_ready_set (my_bool x); +my_bool wsrep_ready_set (my_bool x); ssize_t wsrep_sst_prepare (void** msg); wsrep_cb_status wsrep_sst_donate_cb (void* app_ctx, diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 94804a6d3c7b7a93489d2699801be262b27f6d5e..4df969496bcdf7bce28a18aa95900299f75c3336 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -85,37 +85,14 @@ static void make_wsrep_defaults_file() } -// TODO: Improve address verification. -static bool sst_receive_address_check (const char* str) -{ - if (!strncasecmp(str, "127.0.0.1", strlen("127.0.0.1")) || - !strncasecmp(str, "localhost", strlen("localhost"))) - { - return 1; - } - - return 0; -} - bool wsrep_sst_receive_address_check (sys_var *self, THD* thd, set_var* var) { - char addr_buf[FN_REFLEN]; - if ((! var->save_result.string_value.str) || (var->save_result.string_value.length > (FN_REFLEN - 1))) // safety { goto err; } - memcpy(addr_buf, var->save_result.string_value.str, - var->save_result.string_value.length); - addr_buf[var->save_result.string_value.length]= 0; - - if (sst_receive_address_check(addr_buf)) - { - goto err; - } - return 0; err: @@ -182,8 +159,8 @@ bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type) void wsrep_sst_auth_init (const char* value) { - if (wsrep_sst_auth == value) wsrep_sst_auth = NULL; - if (value) sst_auth_real_set (value); + DBUG_ASSERT(wsrep_sst_auth == value); + sst_auth_real_set (wsrep_sst_auth); } bool wsrep_sst_donor_check (sys_var *self, THD* thd, set_var* var) @@ -579,11 +556,11 @@ static ssize_t sst_prepare_other (const char* method, ret= snprintf (cmd_str(), cmd_len, "wsrep_sst_%s " - WSREP_SST_OPT_ROLE" 'joiner' " - WSREP_SST_OPT_ADDR" '%s' " - WSREP_SST_OPT_DATA" '%s' " + WSREP_SST_OPT_ROLE " 'joiner' " + WSREP_SST_OPT_ADDR " '%s' " + WSREP_SST_OPT_DATA " '%s' " " %s " - WSREP_SST_OPT_PARENT" '%d'" + WSREP_SST_OPT_PARENT " '%d'" " %s '%s' ", method, addr_in, mysql_real_data_home, wsrep_defaults_file, @@ -865,13 +842,13 @@ static int sst_donate_mysqldump (const char* addr, int ret= snprintf (cmd_str(), cmd_len, "wsrep_sst_mysqldump " - WSREP_SST_OPT_ADDR" '%s' " - WSREP_SST_OPT_PORT" '%d' " - WSREP_SST_OPT_LPORT" '%u' " - WSREP_SST_OPT_SOCKET" '%s' " - " '%s' " - WSREP_SST_OPT_GTID" '%s:%lld' " - WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'" + WSREP_SST_OPT_ADDR " '%s' " + WSREP_SST_OPT_PORT " '%d' " + WSREP_SST_OPT_LPORT " '%u' " + WSREP_SST_OPT_SOCKET " '%s' " + " %s " + WSREP_SST_OPT_GTID " '%s:%lld' " + WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" "%s", addr, port, mysqld_port, mysqld_unix_port, wsrep_defaults_file, uuid_str, @@ -1228,14 +1205,14 @@ static int sst_donate_other (const char* method, ret= snprintf (cmd_str(), cmd_len, "wsrep_sst_%s " - WSREP_SST_OPT_ROLE" 'donor' " - WSREP_SST_OPT_ADDR" '%s' " - WSREP_SST_OPT_SOCKET" '%s' " - WSREP_SST_OPT_DATA" '%s' " + WSREP_SST_OPT_ROLE " 'donor' " + WSREP_SST_OPT_ADDR " '%s' " + WSREP_SST_OPT_SOCKET " '%s' " + WSREP_SST_OPT_DATA " '%s' " " %s " " %s '%s' " - WSREP_SST_OPT_GTID" '%s:%lld' " - WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'" + WSREP_SST_OPT_GTID " '%s:%lld' " + WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" "%s", method, addr, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 7b73273b8a99a3848aebb75da5dfa2fbd7e72781..eb26da6128273d01a08d99dd04a6fb53619ee253 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -47,7 +47,7 @@ int wsrep_show_bf_aborts (THD *thd, SHOW_VAR *var, char *buff, return 0; } -/* must have (&thd->LOCK_wsrep_thd) */ +/* must have (&thd->LOCK_thd_data) */ void wsrep_client_rollback(THD *thd) { WSREP_DEBUG("client rollback due to BF abort for (%ld), query: %s", @@ -56,7 +56,7 @@ void wsrep_client_rollback(THD *thd) WSREP_ATOMIC_ADD_LONG(&wsrep_bf_aborts_counter, 1); thd->wsrep_conflict_state= ABORTING; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); trans_rollback(thd); if (thd->locked_tables_mode && thd->lock) @@ -83,7 +83,7 @@ void wsrep_client_rollback(THD *thd) WSREP_DEBUG("clearing binlog table map for BF abort (%ld)", thd->thread_id); thd->clear_binlog_table_maps(); } - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_conflict_state= ABORTED; } @@ -229,7 +229,7 @@ void wsrep_replay_transaction(THD *thd) thd->get_stmt_da()->reset_diagnostics_area(); thd->wsrep_conflict_state= REPLAYING; - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); thd->reset_for_next_command(); thd->reset_killed(); @@ -269,7 +269,7 @@ void wsrep_replay_transaction(THD *thd) if (thd->wsrep_conflict_state!= REPLAYING) WSREP_WARN("lost replaying mode: %d", thd->wsrep_conflict_state ); - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); switch (rcode) { @@ -326,7 +326,7 @@ void wsrep_replay_transaction(THD *thd) /* we're now in inconsistent state, must abort */ /* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */ - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); unireg_abort(1); break; @@ -496,29 +496,29 @@ static void wsrep_rollback_process(THD *thd) */ mysql_mutex_unlock(&LOCK_wsrep_rollback); - mysql_mutex_lock(&aborting->LOCK_wsrep_thd); + mysql_mutex_lock(&aborting->LOCK_thd_data); if (aborting->wsrep_conflict_state== ABORTED) { WSREP_DEBUG("WSREP, thd already aborted: %llu state: %d", (long long)aborting->real_id, aborting->wsrep_conflict_state); - mysql_mutex_unlock(&aborting->LOCK_wsrep_thd); + mysql_mutex_unlock(&aborting->LOCK_thd_data); mysql_mutex_lock(&LOCK_wsrep_rollback); continue; } aborting->wsrep_conflict_state= ABORTING; - mysql_mutex_unlock(&aborting->LOCK_wsrep_thd); + mysql_mutex_unlock(&aborting->LOCK_thd_data); set_current_thd(aborting); aborting->store_globals(); - mysql_mutex_lock(&aborting->LOCK_wsrep_thd); + mysql_mutex_lock(&aborting->LOCK_thd_data); wsrep_client_rollback(aborting); WSREP_DEBUG("WSREP rollbacker aborted thd: (%lu %llu)", aborting->thread_id, (long long)aborting->real_id); - mysql_mutex_unlock(&aborting->LOCK_wsrep_thd); + mysql_mutex_unlock(&aborting->LOCK_thd_data); set_current_thd(thd); thd->store_globals(); @@ -558,10 +558,10 @@ enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd, my_bool sync) enum wsrep_conflict_state state = NO_CONFLICT; if (thd) { - if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_lock(&thd->LOCK_thd_data); state = thd->wsrep_conflict_state; - if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data); } return state; } @@ -585,12 +585,12 @@ my_bool wsrep_thd_is_BF(THD *thd, my_bool sync) if (wsrep_thd_is_wsrep(thd)) { if (sync) - mysql_mutex_lock(&thd->LOCK_wsrep_thd); + mysql_mutex_lock(&thd->LOCK_thd_data); status = ((thd->wsrep_exec_mode == REPL_RECV) || (thd->wsrep_exec_mode == TOTAL_ORDER)); if (sync) - mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + mysql_mutex_unlock(&thd->LOCK_thd_data); } } return status; @@ -603,12 +603,12 @@ my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync) if (thd_ptr) { THD* thd = (THD*)thd_ptr; - if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_lock(&thd->LOCK_thd_data); status = ((thd->wsrep_exec_mode == REPL_RECV) || (thd->wsrep_exec_mode == TOTAL_ORDER) || (thd->wsrep_exec_mode == LOCAL_COMMIT)); - if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data); } return status; } @@ -620,10 +620,10 @@ my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync) if (thd_ptr) { THD* thd = (THD*)thd_ptr; - if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_lock(&thd->LOCK_thd_data); status = (thd->wsrep_exec_mode == LOCAL_STATE); - if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd); + if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data); } return status; } diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index ad1f4ec0eac6a5a668c870a435b7478a3eee5738..216bab0cdcdcdc1f86a87469921a37d40edc678d 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -34,6 +34,7 @@ const char* wsrep_node_name = 0; const char* wsrep_node_address = 0; const char* wsrep_node_incoming_address = 0; const char* wsrep_start_position = 0; +ulong wsrep_reject_queries; static long wsrep_prev_slave_threads = wsrep_slave_threads; @@ -68,6 +69,9 @@ bool wsrep_on_check(sys_var *self, THD* thd, set_var* var) { bool new_wsrep_on= (bool)var->save_result.ulonglong_value; + if (check_has_super(self, thd, var)) + return true; + if (new_wsrep_on && innodb_lock_schedule_algorithm != 0) { my_message(ER_WRONG_ARGUMENTS, " WSREP (galera) can't be enabled " "if innodb_lock_schedule_algorithm=VATS. Please configure" @@ -384,6 +388,27 @@ void wsrep_provider_options_init(const char* value) wsrep_provider_options = (value) ? my_strdup(value, MYF(0)) : NULL; } +bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type) +{ + switch (wsrep_reject_queries) { + case WSREP_REJECT_NONE: + WSREP_INFO("Allowing client queries due to manual setting"); + break; + case WSREP_REJECT_ALL: + WSREP_INFO("Rejecting client queries due to manual setting"); + break; + case WSREP_REJECT_ALL_KILL: + wsrep_close_client_connections(FALSE); + WSREP_INFO("Rejecting client queries and killing connections due to manual setting"); + break; + default: + WSREP_INFO("Unknown value for wsrep_reject_queries: %lu", + wsrep_reject_queries); + return true; + } + return false; +} + static int wsrep_cluster_address_verify (const char* cluster_address_str) { /* There is no predefined address format, it depends on provider. */ diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h index 55eb2fbc501cdb9273d77ffdfc5a8b518d914c22..53952173c8348779a0723800207e3ca1ccf1766e 100644 --- a/sql/wsrep_var.h +++ b/sql/wsrep_var.h @@ -93,6 +93,7 @@ extern bool wsrep_desync_update UPDATE_ARGS; extern bool wsrep_max_ws_size_check CHECK_ARGS; extern bool wsrep_max_ws_size_update UPDATE_ARGS; +extern bool wsrep_reject_queries_update UPDATE_ARGS; #else /* WITH_WSREP */ diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index 1b15fa16ce49e49e447d8bc05b0a4b85b7232b95..e87bc70ade45dff5b4fb438b4579d0fb4e1f798d 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -408,8 +408,7 @@ static void print_version(void) static void get_options(int *argc, char ***argv) { - if (load_defaults("my", load_default_groups, argc, argv)) - exit(1); + load_defaults_or_exit("my", load_default_groups, argc, argv); default_argv= *argv; handle_options(argc, argv, my_long_options, get_one_option); diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 6842319b86dfb369b516d0980a21f62bdb856072..d70757e8142a9f1e3b3db06268ceed0e8064dc77 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1888,7 +1888,7 @@ maria_declare_plugin(archive) &archive_storage_engine, "ARCHIVE", "Brian Aker, MySQL AB", - "Archive storage engine", + "gzip-compresses tables for a low storage footprint", PLUGIN_LICENSE_GPL, archive_db_init, /* Plugin Init */ NULL, /* Plugin Deinit */ diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index e283da97c4bf087945a71b2582c60d22950c9779..6e8c8baf90e14c108e0c1c35f64ef027257dd4f8 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -230,7 +230,7 @@ ENDIF(CONNECT_WITH_ODBC) # # JDBC with MongoDB Java Driver included but disabled if without MONGO # -# OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON) +#OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON) OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON) IF(CONNECT_WITH_JDBC) @@ -326,6 +326,13 @@ IF(NOT TARGET connect) RETURN() ENDIF() +IF(WIN32) + IF (libmongoc-1.0_FOUND) + SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS + "/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll") + ENDIF(libmongoc-1.0_FOUND) +ENDIF(WIN32) + # Install some extra files that belong to connect engine IF(WIN32) # install ha_connect.lib diff --git a/storage/connect/Client.java b/storage/connect/Client.java index aaf1b7bf2f80ccf2d3c2d127cb53026fd82127c3..afa54fa42567eac7d44d303e64d22719b1b64f6e 100644 --- a/storage/connect/Client.java +++ b/storage/connect/Client.java @@ -1,9 +1,13 @@ + package wrappers; import java.io.BufferedReader; import java.io.Console; import java.io.IOException; import java.io.InputStreamReader; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; public class Client { static boolean DEBUG = true; @@ -58,6 +62,9 @@ public class Client { String query; System.out.println("Successfully connected to " + parms[1]); + s = jdi.GetQuoteString(); + System.out.println("Qstr = '" + s + "'"); + while ((query = getLine("Query: ", false)) != null) { n = jdi.Execute(query); System.out.println("Returned n = " + n); @@ -79,7 +86,11 @@ public class Client { private static void PrintResult(int ncol) { // Get result set meta data int i; + Date date = new Date(0); + Time time = new Time(0); + Timestamp tsp = new Timestamp(0); String columnName; + Object job; // Get the column names; column indices start from 1 for (i = 1; i <= ncol; i++) { @@ -112,6 +123,7 @@ public class Client { case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: case java.sql.Types.CHAR: + case 1111: System.out.print(jdi.StringField(i, null)); break; case java.sql.Types.INTEGER: @@ -120,14 +132,17 @@ public class Client { case java.sql.Types.BIGINT: System.out.print(jdi.BigintField(i, null)); break; - case java.sql.Types.TIMESTAMP: - System.out.print(jdi.TimestampField(i, null)); - break; case java.sql.Types.TIME: - System.out.print(jdi.TimeField(i, null)); + time.setTime((long)jdi.TimeField(i, null) * 1000); + System.out.print(time); break; case java.sql.Types.DATE: - System.out.print(jdi.DateField(i, null)); + date.setTime((long)jdi.DateField(i, null) * 1000); + System.out.print(date); + break; + case java.sql.Types.TIMESTAMP: + tsp.setTime((long)jdi.TimestampField(i, null) * 1000); + System.out.print(tsp); break; case java.sql.Types.SMALLINT: System.out.print(jdi.IntField(i, null)); @@ -141,6 +156,8 @@ public class Client { case java.sql.Types.BOOLEAN: System.out.print(jdi.BooleanField(i, null)); default: + job = jdi.ObjectField(i, null); + System.out.print(job.toString()); break; } // endswitch Type diff --git a/storage/connect/JavaWrappers.jar b/storage/connect/JavaWrappers.jar index ef407f6a9c2d1e0ad1730c4b7194b012572ba8ce..33b29e7685b66ee03d1b3f5921f2ba32d48f76b3 100644 Binary files a/storage/connect/JavaWrappers.jar and b/storage/connect/JavaWrappers.jar differ diff --git a/storage/connect/JdbcInterface.java b/storage/connect/JdbcInterface.java index a1b1360e6ea79cc4580bdc5c9829e59a1e8caf1c..72ee4ab0d39fec43711421f79932a84691a2c7c5 100644 --- a/storage/connect/JdbcInterface.java +++ b/storage/connect/JdbcInterface.java @@ -1,10 +1,22 @@ package wrappers; -import java.math.*; -import java.sql.*; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.Date; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; import java.util.Collections; import java.util.Hashtable; import java.util.List; +import java.util.UUID; import javax.sql.DataSource; @@ -223,6 +235,24 @@ public class JdbcInterface { } // end of SetTimestampParm + public void SetUuidParm(int i, String s) { + try { + UUID uuid; + + if (s == null) + uuid = null; + else if (s.isEmpty()) + uuid = UUID.randomUUID(); + else + uuid = UUID.fromString(s); + + pstmt.setObject(i, uuid); + } catch (Exception e) { + SetErrmsg(e); + } // end try/catch + + } // end of SetUuidParm + public int SetNullParm(int i, int typ) { int rc = 0; @@ -481,6 +511,8 @@ public class JdbcInterface { System.out.println("Executing query '" + query + "'"); try { + if (rs != null) + rs.close(); rs = stmt.executeQuery(query); rsmd = rs.getMetaData(); ncol = rsmd.getColumnCount(); @@ -708,7 +740,7 @@ public class JdbcInterface { return 0; } // end of TimestampField - public Object ObjectField(int n, String name) { + public Object ObjectField(int n, String name) { if (rs == null) { System.out.println("No result set"); } else try { @@ -720,6 +752,22 @@ public class JdbcInterface { return null; } // end of ObjectField + public String UuidField(int n, String name) { + Object job; + + if (rs == null) { + System.out.println("No result set"); + } else + try { + job = (n > 0) ? rs.getObject(n) : rs.getObject(name); + return job.toString(); + } catch (SQLException se) { + SetErrmsg(se); + } // end try/catch + + return null; + } // end of UuidField + public int GetDrivers(String[] s, int mxs) { int n = 0; List drivers = Collections.list(DriverManager.getDrivers()); diff --git a/storage/connect/PostgresqlInterface.java b/storage/connect/PostgresqlInterface.java index adce0616a1b15c99eed67d27287a7ab85acb0f3c..9f611eeb23b0dd32eed4d8235c8804166012aa07 100644 --- a/storage/connect/PostgresqlInterface.java +++ b/storage/connect/PostgresqlInterface.java @@ -1,9 +1,10 @@ package wrappers; -import java.sql.*; +import java.sql.SQLException; import java.util.Hashtable; import javax.sql.DataSource; + import org.postgresql.jdbc2.optional.PoolingDataSource; public class PostgresqlInterface extends JdbcInterface { @@ -19,7 +20,7 @@ public class PostgresqlInterface extends JdbcInterface { } // end of constructor - @Override + @Override public int JdbcConnect(String[] parms, int fsize, boolean scrollable) { int rc = 0; String url = parms[1]; diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 639edf63a1a9fa81872d85d436f4e671b5d731b6..cd1785b48ac20f9aa02cdfc2b87617d2431787fc 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -82,7 +82,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp) if ((valtyp = pp->Type) != TYPE_STRING) len = 1; - if (trace) + if (trace(1)) htrc("valtyp=%d len=%d\n", valtyp, len); /*********************************************************************/ @@ -287,7 +287,7 @@ bool ARRAY::AddValue(PGLOBAL g, PSZ strp) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding string(%d): '%s'\n", Nval, strp); //Value->SetValue_psz(strp); @@ -306,7 +306,7 @@ bool ARRAY::AddValue(PGLOBAL g, void *p) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding pointer(%d): %p\n", Nval, p); Vblp->SetValue((PSZ)p, Nval++); @@ -323,7 +323,7 @@ bool ARRAY::AddValue(PGLOBAL g, short n) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding SHORT(%d): %hd\n", Nval, n); //Value->SetValue(n); @@ -342,7 +342,7 @@ bool ARRAY::AddValue(PGLOBAL g, int n) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding int(%d): %d\n", Nval, n); //Value->SetValue(n); @@ -361,7 +361,7 @@ bool ARRAY::AddValue(PGLOBAL g, double d) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding float(%d): %lf\n", Nval, d); Value->SetValue(d); @@ -380,7 +380,7 @@ bool ARRAY::AddValue(PGLOBAL g, PXOB xp) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding (%d) from xp=%p\n", Nval, xp); //AddValue(xp->GetValue()); @@ -399,7 +399,7 @@ bool ARRAY::AddValue(PGLOBAL g, PVAL vp) return true; } // endif Type - if (trace) + if (trace(1)) htrc(" adding (%d) from vp=%p\n", Nval, vp); Vblp->SetValue(vp, Nval++); @@ -520,7 +520,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm) } else if (opc != OP_EXIST) { sprintf(g->Message, MSG(MISSING_ARG), opc); - throw (int)TYPE_ARRAY; + throw (int)TYPE_ARRAY; } else // OP_EXIST return Nval > 0; @@ -990,7 +990,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g) len += strlen(tp); } // enfor i - if (trace) + if (trace(1)) htrc("Arraylist: len=%d\n", len); p = (char *)PlugSubAlloc(g, NULL, len); @@ -1003,7 +1003,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g) strcat(p, (++i == Nval) ? ")" : ","); } // enfor i - if (trace) + if (trace(1)) htrc("Arraylist: newlen=%d\n", strlen(p)); return p; diff --git a/storage/connect/blkfil.cpp b/storage/connect/blkfil.cpp index 802095f2f82f31cad45e16bc61d3bb718310e33a..76c9d09ac934cf7a0562bc8547cba6e4eea616e6 100644 --- a/storage/connect/blkfil.cpp +++ b/storage/connect/blkfil.cpp @@ -241,7 +241,7 @@ int BLKFILARI::BlockEval(PGLOBAL) break; } // endswitch Opc - if (trace) + if (trace(1)) htrc("BlockEval: op=%d n=%d rc=%d\n", Opc, n, Result); return Result; @@ -338,7 +338,7 @@ int BLKFILAR2::BlockEval(PGLOBAL) break; } // endswitch Opc - if (trace) + if (trace(1)) htrc("BlockEval2: op=%d n=%d rc=%d\n", Opc, n, Result); return Result; @@ -474,7 +474,7 @@ int BLKFILMR2::BlockEval(PGLOBAL) break; } // endswitch Opc - if (trace) + if (trace(1)) htrc("BlockEval2: op=%d n=%d rc=%d\n", Opc, n, Result); return Result; @@ -567,7 +567,7 @@ int BLKSPCARI::BlockEval(PGLOBAL) break; } // endswitch Opc - if (trace) + if (trace(1)) htrc("BlockEval: op=%d n=%d rc=%d\n", Opc, n, Result); return Result; diff --git a/storage/connect/block.h b/storage/connect/block.h index 8ac7be80988b700eb26eedc2a325b0e793b39676..737c74c129360237187d18a053edeca5d7697e89 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -38,8 +38,8 @@ typedef class BLOCK *PBLOCK; class DllExport BLOCK { public: void * operator new(size_t size, PGLOBAL g, void *p = NULL) { -// if (trace > 3) -// htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); + if (trace(256)) + htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); return (PlugSubAlloc(g, p, size)); } // end of new diff --git a/storage/connect/checklvl.h b/storage/connect/checklvl.h index 0c234dfb8b85a53aa5825e5fb13b76fed875a59b..9029e616bb656087eeeb9cfe39d83e017000d5e5 100644 --- a/storage/connect/checklvl.h +++ b/storage/connect/checklvl.h @@ -45,6 +45,7 @@ enum USETEMP {TMP_NO = 0, /* Never */ /***********************************************************************/ enum TYPCONV {TPC_NO = 0, /* Never */ TPC_YES = 1, /* Always */ - TPC_SKIP = 2}; /* Skip TEXT columns */ + TPC_FORCE = 2, /* Also convert BLOBs */ + TPC_SKIP = 3}; /* Skip TEXT columns */ #endif // _CHKLVL_DEFINED_ diff --git a/storage/connect/cmgoconn.cpp b/storage/connect/cmgoconn.cpp index 44fac56137f341a8639974e1571b749f6c1b89a6..edee1874b972b1d21c5225abd711e7f9e25eca43 100644 --- a/storage/connect/cmgoconn.cpp +++ b/storage/connect/cmgoconn.cpp @@ -280,7 +280,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g) all = true; if (Pcg->Pipe) { - if (trace) + if (trace(1)) htrc("Pipeline: %s\n", options); p = strrchr(options, ']'); @@ -330,7 +330,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g) *(char*)p = ']'; // Restore Colist for discovery p = s->GetStr(); - if (trace) + if (trace(33)) htrc("New Pipeline: %s\n", p); Query = bson_new_from_json((const uint8_t *)p, -1, &Error); @@ -350,7 +350,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g) } else { if (Pcg->Filter || filp) { - if (trace) { + if (trace(1)) { if (Pcg->Filter) htrc("Filter: %s\n", Pcg->Filter); @@ -377,7 +377,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g) tp->SetFilter(NULL); // Not needed anymore } // endif To_Filter - if (trace) + if (trace(33)) htrc("selector: %s\n", s->GetStr()); s->Resize(s->GetLength() + 1); @@ -393,7 +393,7 @@ bool CMgoConn::MakeCursor(PGLOBAL g) if (!all) { if (options && *options) { - if (trace) + if (trace(1)) htrc("options=%s\n", options); p = options; @@ -450,10 +450,10 @@ int CMgoConn::ReadNext(PGLOBAL g) if (!Cursor && MakeCursor(g)) { rc = RC_FX; } else if (mongoc_cursor_next(Cursor, &Document)) { - if (trace > 1) { + if (trace(512)) { bson_iter_t iter; ShowDocument(&iter, Document, ""); - } else if (trace == 1) + } else if (trace(1)) htrc("%s\n", GetDocument(g)); } else if (mongoc_cursor_error(Cursor, &Error)) { @@ -589,7 +589,7 @@ int CMgoConn::Write(PGLOBAL g) if (DocWrite(g, Fpc)) return RC_FX; - if (trace) { + if (trace(2)) { char *str = bson_as_json(Fpc->Child, NULL); htrc("Inserting: %s\n", str); bson_free(str); @@ -623,7 +623,7 @@ int CMgoConn::Write(PGLOBAL g) } // endif iter if (b) { - if (trace) { + if (trace(2)) { char *str = bson_as_json(query, NULL); htrc("update query: %s\n", str); bson_free(str); diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index 2ffe51d2009c93f8631c914cacfc100c172d87f1..a9cf43f3d9678e4b4a94280f61c40c53e3bfc3b3 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -76,7 +76,7 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) //To_Orig = col1; To_Tdb = tdbp; - if (trace > 1) + if (trace(2)) htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); if (tdbp) @@ -115,7 +115,7 @@ bool COLBLK::SetFormat(PGLOBAL, FORMAT& fmt) { fmt = Format; - if (trace > 1) + if (trace(2)) htrc("COLBLK: %p format=%c(%d,%d)\n", this, *fmt.Type, fmt.Length, fmt.Prec); @@ -128,7 +128,7 @@ bool COLBLK::SetFormat(PGLOBAL, FORMAT& fmt) /***********************************************************************/ bool COLBLK::Eval(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("Col Eval: %s status=%.4X\n", Name, Status); if (!GetStatus(BUF_READ)) { @@ -165,7 +165,7 @@ bool COLBLK::InitValue(PGLOBAL g) AddStatus(BUF_READY); Value->SetNullable(Nullable); - if (trace > 1) + if (trace(2)) htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", this, Buf_Type, Value, ColUse, Status); @@ -412,4 +412,3 @@ void SIDBLK::ReadColumn(PGLOBAL) // } // endif Sname } // end of ReadColumn - diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 5e80201fccf0da6f18d2f09de3463e02c42fa096..39123b18c593f375ae3fe22b46076075802486c7 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -92,7 +92,7 @@ void CntEndDB(PGLOBAL g) free(dbuserp); - if (trace) + if (trace(1)) htrc("CntEndDB: Freeing Dup\n"); g->Activityp->Aptr = NULL; @@ -112,14 +112,14 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname) bool rc= false; PDBUSER dbuserp= PlgGetUser(g); - if (trace) { + if (trace(1)) { printf("CntCheckDB: dbuserp=%p\n", dbuserp); } // endif trace if (!dbuserp || !handler) return true; - if (trace) + if (trace(1)) printf("cat=%p oldhandler=%p newhandler=%p\n", dbuserp->Catalog, (dbuserp->Catalog) ? ((MYCAT*)dbuserp->Catalog)->GetHandler() : NULL, handler); @@ -150,7 +150,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname) /*********************************************************************/ sprintf(g->Message, MSG(DATABASE_LOADED), "???"); - if (trace) + if (trace(1)) printf("msg=%s\n", g->Message); return rc; @@ -198,7 +198,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) PDBUSER dup = PlgGetUser(g); volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over throw - if (trace) + if (trace(1)) printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat); if (!cat) @@ -208,7 +208,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) // Get table object from the catalog tabp = new(g) XTAB(name); - if (trace) + if (trace(1)) printf("CntGetTDB: tabp=%p\n", tabp); // Perhaps this should be made thread safe @@ -218,13 +218,13 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) printf("CntGetTDB: %s\n", g->Message); } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); } catch (const char *msg) { strcpy(g->Message, msg); } // end catch - if (trace) + if (trace(1)) printf("Returning tdbp=%p mode=%d\n", tdbp, mode); return tdbp; @@ -243,7 +243,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, //PCOLUMN cp; PDBUSER dup= PlgGetUser(g); - if (trace) + if (trace(1)) printf("CntOpenTable: tdbp=%p mode=%d\n", tdbp, mode); if (!tdbp) { @@ -260,7 +260,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, } else for (p = c1; *p; p += n) { // Allocate only used column blocks - if (trace) + if (trace(1)) printf("Allocating column %s\n", p); g->Message[0] = 0; // To check whether ColDB made an error message @@ -325,7 +325,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, tdbp->SetSetCols(tdbp->GetColumns()); // Now do open the physical table - if (trace) + if (trace(1)) printf("Opening table %s in mode %d tdbp=%p\n", tdbp->GetName(), mode, tdbp); @@ -341,7 +341,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, } // endif del - if (trace) + if (trace(1)) printf("About to open the table: tdbp=%p\n", tdbp); if (mode != MODE_ANY && mode != MODE_ALTER) { @@ -356,7 +356,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, rcop = false; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); } catch (const char *msg) { strcpy(g->Message, msg); @@ -399,12 +399,13 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr) } // endfor colp } catch (int n) { - if (trace) + if (trace(1)) printf("Error %d reading columns: %s\n", n, g->Message); rc = RC_FX; } catch (const char *msg) { strcpy(g->Message, msg); + rc = RC_NF; } // end catch return rc; @@ -549,7 +550,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) return rc; } // endif !USE_OPEN - if (trace) + if (trace(1)) printf("CntCloseTable: tdbp=%p mode=%d nox=%d abort=%d\n", tdbp, tdbp->GetMode(), nox, abort); @@ -579,11 +580,11 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) tdbp->CloseDB(g); tdbp->SetAbort(false); - if (trace > 1) + if (trace(2)) printf("Table %s closed\n", tdbp->GetName()); if (!nox && tdbp->GetMode() != MODE_READ && tdbp->GetMode() != MODE_ANY) { - if (trace > 1) + if (trace(2)) printf("About to reset opt\n"); if (!tdbp->IsRemote()) { @@ -603,7 +604,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) rc = RC_FX; } // end catch - if (trace > 1) + if (trace(2)) htrc("Done rc=%d\n", rc); return (rc == RC_OK || rc == RC_INFO) ? 0 : rc; @@ -922,7 +923,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, valp->SetBinValue((void*)p); #endif // !WORDS_BIGENDIAN - if (trace) { + if (trace(1)) { char bf[32]; printf("i=%d n=%d key=%s\n", i, n, valp->GetCharString(bf)); } // endif trace @@ -944,7 +945,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, xbp->SetNval(n); - if (trace) + if (trace(1)) printf("xbp=%p Nval=%d i=%d incl=%d\n", xbp, n, i, incl[i]); k[i]= xbp->Range(g, i + 1, incl[i]); @@ -953,7 +954,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, } // endfor i - if (trace) + if (trace(1)) printf("k1=%d k0=%d\n", k[1], k[0]); return k[1] - k[0]; diff --git a/storage/connect/csort.cpp b/storage/connect/csort.cpp index 13f325d8f3f7a166347abba66b4d2270f5ce10c2..670131b8fd2f6d5bd8b1618e86bce0e2725b50f2 100644 --- a/storage/connect/csort.cpp +++ b/storage/connect/csort.cpp @@ -351,7 +351,7 @@ void CSORT::Qstx(int *base, int *max) zlo = zhi = cnm = 0; // Avoid warning message - lo = max - base; // Number of elements as longs + lo = (int)(max - base); // Number of elements as longs if (Dup) cnm = Cmpnum(lo); @@ -472,7 +472,7 @@ void CSORT::Qstx(int *base, int *max) i = him + 1; if (Pof) - Pof[him - Pex] = Pof[mid - Pex] = i - j; + Pof[him - Pex] = Pof[mid - Pex] = (int)(i - j); /*******************************************************************/ /* Look at sizes of the two partitions, do the smaller one first */ @@ -481,8 +481,8 @@ void CSORT::Qstx(int *base, int *max) /* But only repeat (recursively or by branching) if the partition */ /* is of at least size THRESH. */ /*******************************************************************/ - lo = j - base; - hi = max - i; + lo = (int)(j - base); + hi = (int)(max - i); if (Dup) { // Update progress information zlo = Cmpnum(lo); @@ -726,7 +726,7 @@ void CSORT::Qstc(int *base, int *max) zlo = zhi = cnm = 0; // Avoid warning message - lo = max - base; // Number of elements as longs + lo = (int)(max - base); // Number of elements as longs if (Dup) cnm = Cmpnum(lo); @@ -853,7 +853,7 @@ void CSORT::Qstc(int *base, int *max) /* the offset array values indicating break point and block size. */ /*******************************************************************/ if (Pof) - Pof[lt - Pex] = Pof[(jj - 1) - Pex] = jj - lt; + Pof[lt - Pex] = Pof[(jj - 1) - Pex] = (int)(jj - lt); /*******************************************************************/ /* Look at sizes of the two partitions, do the smaller one first */ @@ -862,8 +862,8 @@ void CSORT::Qstc(int *base, int *max) /* But only repeat (recursively or by branching) if the partition */ /* is of at least size THRESH. */ /*******************************************************************/ - lo = lt - base; - hi = gt - Swix; + lo = (int)(lt - base); + hi = (int)(gt - Swix); if (Dup) { // Update progress information zlo = Cmpnum(lo); diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp index e24e10835c187a273cd74179d15a8054bf7a4120..ba8eb829abde08bd3718bfcc5eefa9390550cff3 100644 --- a/storage/connect/domdoc.cpp +++ b/storage/connect/domdoc.cpp @@ -13,6 +13,7 @@ #elif defined(MSX4) #import "msxml4.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ?? #elif defined(MSX6) +#pragma warning(suppress : 4192) #import "msxml6.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ?? #else // MSX4 #error MSX? is not defined @@ -540,7 +541,7 @@ PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np) // If name has the format m[n] only m is taken as node name if ((p = strchr(name, '['))) - pn = BufAlloc(g, name, p - name); + pn = BufAlloc(g, name, (int)(p - name)); else pn = name; diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 84dff422db71be76074fadb3bf2055552ae77331..6e71e1bf2cd4faa3d721d63d46195207bf5e0ea3 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -90,7 +90,7 @@ int MAPFAM::GetFileLength(PGLOBAL g) len = (To_Fb && To_Fb->Count) ? To_Fb->Length : TXTFAM::GetFileLength(g); - if (trace) + if (trace(1)) htrc("Mapped file length=%d\n", len); return len; @@ -128,7 +128,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) && fp->Count && fp->Mode == mode) break; - if (trace) + if (trace(1)) htrc("Mapping file, fp=%p\n", fp); } else @@ -166,7 +166,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int) rc, filename); - if (trace) + if (trace(1)) htrc("CreateFileMap: %s\n", g->Message); return (mode == MODE_READ && rc == ENOENT) @@ -227,7 +227,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) Fpos = Mempos = Memory; Top = Memory + len; - if (trace) + if (trace(1)) htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n", fp, fp->Count, Memory, len, Top); @@ -247,7 +247,7 @@ int MAPFAM::GetRowID(void) /***********************************************************************/ int MAPFAM::GetPos(void) { - return Fpos - Memory; + return (int)(Fpos - Memory); } // end of GetPos /***********************************************************************/ @@ -255,7 +255,7 @@ int MAPFAM::GetPos(void) /***********************************************************************/ int MAPFAM::GetNextPos(void) { - return Mempos - Memory; + return (int)(Mempos - Memory); } // end of GetNextPos /***********************************************************************/ @@ -368,7 +368,7 @@ int MAPFAM::ReadBuffer(PGLOBAL g) } // endif Mempos // Set caller line buffer - len = (Mempos - Fpos) - n; + len = (int)(Mempos - Fpos) - n; // Don't rely on ENDING setting if (len > 0 && *(Mempos - 2) == '\r') @@ -407,7 +407,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) { int n; - if (trace) + if (trace(1)) htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n", irc, Mempos, To_Buf, Tpos, Spos); @@ -417,7 +417,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = Top; - if (trace) + if (trace(1)) htrc("Fpos placed at file top=%p\n", Fpos); } // endif irc @@ -428,14 +428,14 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /* not required here, just setting of future Spos and Tpos. */ /*******************************************************************/ Tpos = Spos = Fpos; - } else if ((n = Fpos - Spos) > 0) { + } else if ((n = (int)(Fpos - Spos)) > 0) { /*******************************************************************/ /* Non consecutive line to delete. Move intermediate lines. */ /*******************************************************************/ memmove(Tpos, Spos, n); Tpos += n; - if (trace) + if (trace(1)) htrc("move %d bytes\n", n); } // endif n @@ -443,7 +443,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) if (irc == RC_OK) { Spos = Mempos; // New start position - if (trace) + if (trace(1)) htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); } else if (To_Fb) { // Can be NULL for deleted files @@ -461,7 +461,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) /*****************************************************************/ /* Remove extra records. */ /*****************************************************************/ - n = Tpos - Memory; + n = (int)(Tpos - Memory); #if defined(__WIN__) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); @@ -473,7 +473,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) return RC_FX; } // endif - if (trace) + if (trace(1)) htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); if (!SetEndOfFile(fp->Handle)) { @@ -511,7 +511,7 @@ void MAPFAM::CloseTableFile(PGLOBAL g, bool) PlugCloseFile(g, To_Fb); //To_Fb = NULL; // To get correct file size in Cardinality - if (trace) + if (trace(1)) htrc("MAP Close: closing %s count=%d\n", To_File, (To_Fb) ? To_Fb->Count : 0); @@ -627,7 +627,7 @@ int MBKFAM::ReadBuffer(PGLOBAL g) break; // Set caller line buffer - len = (Mempos - Fpos) - Ending; + len = (int)(Mempos - Fpos) - Ending; memcpy(Tdbp->GetLine(), Fpos, len); Tdbp->GetLine()[len] = '\0'; return RC_OK; diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index 44abd962c564faa7a09d8bcd8a087e67bac12004..893e3da0d46402d0f04d3b676500322c18279f9b 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -203,7 +203,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info) PQRYRES qrp; PCOLRES crp; - if (trace) + if (trace(1)) htrc("DBFColumns: File %s\n", SVP(fn)); if (!info) { @@ -245,7 +245,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info) return qrp; } // endif info - if (trace) { + if (trace(1)) { htrc("Structure of %s\n", filename); htrc("headlen=%hd reclen=%hd degree=%d\n", mainhead.Headlen(), mainhead.Reclen(), fields); @@ -271,7 +271,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info) } else len = thisfield.Length; - if (trace) + if (trace(1)) htrc("%-11s %c %6ld %3d %2d %3d %3d\n", thisfield.Name, thisfield.Type, thisfield.Offset, len, thisfield.Decimals, thisfield.Setfield, thisfield.Mdxfield); @@ -522,14 +522,14 @@ bool DBFFAM::OpenTableFile(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); if (!(Stream = PlugOpenFile(g, filename, opmode))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (mode == MODE_READ && errno == ENOENT) ? PushWarning(g, Tdbp) : true; } // endif Stream - if (trace) + if (trace(1)) htrc("File %s is open in mode %s\n", filename, opmode); To_Fb = dbuserp->Openlist; // Keep track of File block @@ -938,7 +938,7 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort) rc = PlugCloseFile(g, To_Fb); fin: - if (trace) + if (trace(1)) htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", To_File, mode, wrc, rc); diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index 1d6194b154d30a211430e9427fe4eb0bb7378fcc..0a98ec5b54ad4ede7aa0cd315ca64140a7ef6e05 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -322,7 +322,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g) return RC_FX; } // endif fseek - if (trace > 1) + if (trace(2)) htrc("File position is now %d\n", ftell(Stream)); if (Padded) @@ -344,7 +344,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return RC_FX; @@ -361,7 +361,7 @@ int FIXFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ int FIXFAM::WriteBuffer(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("FIX WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n", Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum); @@ -374,7 +374,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g) return RC_OK; // We write only full blocks } // endif CurNum - if (trace > 1) + if (trace(2)) htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf); // Now start the writing process. @@ -388,7 +388,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g) CurNum = 0; Tdbp->SetLine(To_Buf); - if (trace > 1) + if (trace(2)) htrc("write done\n"); } else { // Mode == MODE_UPDATE @@ -431,7 +431,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc) /* file, and at the end erase all trailing records. */ /* This will be experimented. */ /*********************************************************************/ - if (trace > 1) + if (trace(2)) htrc("DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, Fpos, Tpos, Spos); @@ -441,7 +441,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = Tdbp->Cardinality(g); - if (trace > 1) + if (trace(2)) htrc("Fpos placed at file end=%d\n", Fpos); } else // Fpos is the deleted line position @@ -491,7 +491,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc) OldBlk = -2; // To force fseek to be executed on next block } // endif moved - if (trace > 1) + if (trace(2)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else { @@ -540,7 +540,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc) close(h); - if (trace > 1) + if (trace(2)) htrc("done, h=%d irc=%d\n", h, irc); } // endif UseTemp @@ -572,7 +572,7 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b) req = (size_t)MY_MIN(n, Dbflen); len = fread(DelBuf, Lrecl, req, Stream); - if (trace > 1) + if (trace(2)) htrc("after read req=%d len=%d\n", req, len); if (len != req) { @@ -591,13 +591,13 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b) return true; } // endif - if (trace > 1) + if (trace(2)) htrc("after write pos=%d\n", ftell(Stream)); Tpos += (int)req; Spos += (int)req; - if (trace > 1) + if (trace(2)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); *b = true; @@ -648,7 +648,7 @@ void FIXFAM::CloseTableFile(PGLOBAL g, bool abort) rc = PlugCloseFile(g, To_Fb); fin: - if (trace) + if (trace(1)) htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", To_File, mode, wrc, rc); @@ -718,7 +718,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); - if (trace > 1) + if (trace(2)) htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr); if (!brc) { @@ -730,7 +730,7 @@ int BGXFAM::BigRead(PGLOBAL g __attribute__((unused)), (LPTSTR)buf, sizeof(buf), NULL); sprintf(g->Message, MSG(READ_ERROR), To_File, buf); - if (trace > 1) + if (trace(2)) htrc("BIGREAD: %s\n", g->Message); rc = -1; @@ -757,7 +757,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); - if (trace > 1) + if (trace(2)) htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); if (!brc || nbw != len) { @@ -775,7 +775,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf); - if (trace > 1) + if (trace(2)) htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", nbw, len, drc, g->Message); @@ -790,7 +790,7 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); - if (trace > 1) + if (trace(2)) htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", nbw, len, errno, g->Message); @@ -828,7 +828,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode); #if defined(__WIN__) @@ -888,7 +888,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) } else rc = 0; - if (trace > 1) + if (trace(2)) htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n", rc, access, share, creation, Hfile, filename); @@ -942,7 +942,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) } else rc = 0; - if (trace > 1) + if (trace(2)) htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n", rc, oflag, tmode, Hfile, filename); @@ -1026,11 +1026,11 @@ int BGXFAM::Cardinality(PGLOBAL g) if (Hfile == INVALID_HANDLE_VALUE) { int h = open64(filename, O_RDONLY, 0); - if (trace) + if (trace(1)) htrc(" h=%d\n", h); if (h == INVALID_HANDLE_VALUE) { - if (trace) + if (trace(1)) htrc(" errno=%d ENOENT=%d\n", errno, ENOENT); if (errno != ENOENT) { @@ -1074,7 +1074,7 @@ int BGXFAM::Cardinality(PGLOBAL g) } else card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file - if (trace) + if (trace(1)) htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n", card, (double)fsize, Lrecl); @@ -1181,7 +1181,7 @@ int BGXFAM::ReadBuffer(PGLOBAL g) if (BigSeek(g, Hfile, (BIGINT)Fpos * (BIGINT)Lrecl)) return RC_FX; - if (trace > 1) + if (trace(2)) htrc("File position is now %d\n", Fpos); nbr = BigRead(g, Hfile, To_Buf, (Padded) ? Blksize : Lrecl * Nrec); @@ -1205,7 +1205,7 @@ int BGXFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ int BGXFAM::WriteBuffer(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("BIG WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n", Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum); @@ -1218,7 +1218,7 @@ int BGXFAM::WriteBuffer(PGLOBAL g) return RC_OK; // We write only full blocks } // endif CurNum - if (trace > 1) + if (trace(2)) htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf); // Now start the writing process. @@ -1229,7 +1229,7 @@ int BGXFAM::WriteBuffer(PGLOBAL g) CurNum = 0; Tdbp->SetLine(To_Buf); - if (trace > 1) + if (trace(2)) htrc("write done\n"); } else { // Mode == MODE_UPDATE @@ -1270,7 +1270,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) /* file, and at the end erase all trailing records. */ /* This will be experimented. */ /*********************************************************************/ - if (trace > 1) + if (trace(2)) htrc("BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, Fpos, Tpos, Spos); @@ -1280,7 +1280,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = Tdbp->Cardinality(g); - if (trace > 1) + if (trace(2)) htrc("Fpos placed at file end=%d\n", Fpos); } else // Fpos is the deleted line position @@ -1318,7 +1318,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) return RC_FX; if (irc == RC_OK) { - if (trace) + if (trace(1)) assert(Spos == Fpos); Spos++; // New start position is on next line @@ -1330,7 +1330,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc) OldBlk = -2; // To force fseek to be executed on next block } // endif moved - if (trace > 1) + if (trace(2)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else if (irc != RC_OK) { @@ -1459,7 +1459,7 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b) Tpos += (int)req; Spos += (int)req; - if (trace > 1) + if (trace(2)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); *b = true; @@ -1510,7 +1510,7 @@ void BGXFAM::CloseTableFile(PGLOBAL g, bool abort) rc = PlugCloseFile(g, To_Fb); fin: - if (trace) + if (trace(1)) htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", To_File, mode, wrc, rc); diff --git a/storage/connect/filamgz.cpp b/storage/connect/filamgz.cpp index df366ef15f9b9bf02a31689abaf1ec283f81633b..880db54c91dab029a5a89d4a328425319130f712 100644 --- a/storage/connect/filamgz.cpp +++ b/storage/connect/filamgz.cpp @@ -203,7 +203,7 @@ bool GZFAM::AllocateBuffer(PGLOBAL g) Buflen = Lrecl + 2; // Lrecl does not include CRLF //Buflen *= ((Mode == MODE_DELETE) ? DOS_BUFF_LEN : 1); NIY - if (trace) + if (trace(1)) htrc("SubAllocating a buffer of %d bytes\n", Buflen); To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); @@ -347,7 +347,7 @@ int GZFAM::ReadBuffer(PGLOBAL g) } else rc = Zerror(g); - if (trace > 1) + if (trace(2)) htrc(" Read: '%s' rc=%d\n", To_Buf, rc); return rc; @@ -389,7 +389,7 @@ void GZFAM::CloseTableFile(PGLOBAL, bool) { int rc = gzclose(Zfile); - if (trace) + if (trace(1)) htrc("GZ CloseDB: closing %s rc=%d\n", To_File, rc); Zfile = NULL; // So we can know whether table is open @@ -537,7 +537,7 @@ int ZBKFAM::ReadBuffer(PGLOBAL g) while (*NxtLine++ != '\n') ; // Set caller line buffer - n = NxtLine - CurLine - Ending; + n = (int)(NxtLine - CurLine - Ending); memcpy(Tdbp->GetLine(), CurLine, n); Tdbp->GetLine()[n] = '\0'; return RC_OK; @@ -588,7 +588,7 @@ int ZBKFAM::ReadBuffer(PGLOBAL g) for (NxtLine = CurLine; *NxtLine++ != '\n';) ; // Set caller line buffer - n = NxtLine - CurLine - Ending; + n = (int)(NxtLine - CurLine - Ending); memcpy(Tdbp->GetLine(), CurLine, n); Tdbp->GetLine()[n] = '\0'; Rbuf = (CurBlk == Block - 1) ? Last : Nrec; @@ -702,7 +702,7 @@ void ZBKFAM::CloseTableFile(PGLOBAL g, bool) } else rc = gzclose(Zfile); - if (trace) + if (trace(1)) htrc("GZ CloseDB: closing %s rc=%d\n", To_File, rc); Zfile = NULL; // So we can know whether table is open @@ -1087,7 +1087,7 @@ bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused))) /***********************************************************************/ int ZLBFAM::ReadBuffer(PGLOBAL g) { - int n; + size_t n; void *rdbuf; /*********************************************************************/ @@ -1299,7 +1299,7 @@ int ZLBFAM::WriteBuffer(PGLOBAL g) else NxtLine = CurLine + Lrecl; - BlkLen = NxtLine - To_Buf; + BlkLen = (int)(NxtLine - To_Buf); if (WriteCompressedBuffer(g)) { Closing = TRUE; // To tell CloseDB about a Write error @@ -1382,7 +1382,7 @@ void ZLBFAM::CloseTableFile(PGLOBAL g, bool) } else rc = fclose(Stream); - if (trace) + if (trace(1)) htrc("ZLB CloseTableFile: closing %s mode=%d rc=%d\n", To_File, Tdbp->GetMode(), rc); @@ -1408,7 +1408,7 @@ void ZLBFAM::Rewind(void) rewind(Stream); - if (!(st = fread(Zlenp, sizeof(int), 1, Stream)) && trace) + if (!(st = fread(Zlenp, sizeof(int), 1, Stream)) && trace(1)) htrc("fread error %d in Rewind", errno); fseek(Stream, *Zlenp + sizeof(int), SEEK_SET); diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index c456ee9e9b72729d43205d658cdbbf983357e6ba..7c222eb3c80957cd12a7f43f5de02d28da2fffac 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -194,12 +194,12 @@ int TXTFAM::GetFileLength(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); h= global_open(g, MSGID_OPEN_MODE_STRERROR, filename, _O_RDONLY); - if (trace) + if (trace(1)) htrc("GetFileLength: fn=%s h=%d\n", filename, h); if (h == -1) { if (errno != ENOENT) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); len = -1; @@ -249,7 +249,7 @@ int TXTFAM::Cardinality(PGLOBAL g) } // endif Padded - if (trace) + if (trace(1)) htrc(" Computed max_K=%d Filen=%d lrecl=%d\n", card, len, Lrecl); @@ -390,7 +390,7 @@ int TXTFAM::UpdateSortedRows(PGLOBAL g) return RC_OK; err: - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return RC_FX; @@ -439,7 +439,7 @@ int TXTFAM::DeleteSortedRows(PGLOBAL g) return RC_OK; err: - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return RC_FX; @@ -512,7 +512,7 @@ int DOSFAM::GetFileLength(PGLOBAL g) if ((len = _filelength(_fileno(Stream))) < 0) sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", To_File); - if (trace) + if (trace(1)) htrc("File length=%d\n", len); return len; @@ -598,14 +598,14 @@ bool DOSFAM::OpenTableFile(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); if (!(Stream = PlugOpenFile(g, filename, opmode))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (mode == MODE_READ && errno == ENOENT) ? PushWarning(g, Tdbp) : true; } // endif Stream - if (trace) + if (trace(1)) htrc("File %s open Stream=%p mode=%s\n", filename, Stream, opmode); To_Fb = dbuserp->Openlist; // Keep track of File block @@ -628,7 +628,7 @@ bool DOSFAM::AllocateBuffer(PGLOBAL g) // Lrecl does not include line ending Buflen = Lrecl + Ending + ((Bin) ? 1 : 0) + 1; // Sergei - if (trace) + if (trace(1)) htrc("SubAllocating a buffer of %d bytes\n", Buflen); To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); @@ -768,7 +768,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g) if (!Stream) return RC_EF; - if (trace > 1) + if (trace(2)) htrc("ReadBuffer: Tdbp=%p To_Line=%p Placed=%d\n", Tdbp, Tdbp->To_Line, Placed); @@ -782,7 +782,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g) CurBlk = (int)Rows++; - if (trace > 1) + if (trace(2)) htrc("ReadBuffer: CurBlk=%d\n", CurBlk); /********************************************************************/ @@ -803,14 +803,14 @@ int DOSFAM::ReadBuffer(PGLOBAL g) } else Placed = false; - if (trace > 1) + if (trace(2)) htrc(" About to read: stream=%p To_Buf=%p Buflen=%d\n", Stream, To_Buf, Buflen); if (fgets(To_Buf, Buflen, Stream)) { p = To_Buf + strlen(To_Buf) - 1; - if (trace > 1) + if (trace(2)) htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p); #if defined(__WIN__) @@ -838,7 +838,7 @@ int DOSFAM::ReadBuffer(PGLOBAL g) } else if (*p == '\n') *p = '\0'; // Eliminate ending new-line character - if (trace > 1) + if (trace(2)) htrc(" To_Buf='%s'\n", To_Buf); strcpy(Tdbp->To_Line, To_Buf); @@ -853,13 +853,13 @@ int DOSFAM::ReadBuffer(PGLOBAL g) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0)); #endif - if (trace) + if (trace(1)) htrc("%s\n", g->Message); rc = RC_FX; } // endif's fgets - if (trace > 1) + if (trace(2)) htrc("ReadBuffer: rc=%d\n", rc); IsRead = true; @@ -895,7 +895,7 @@ int DOSFAM::WriteBuffer(PGLOBAL g) /*******************************************************************/ curpos = ftell(Stream); - if (trace) + if (trace(1)) htrc("Last : %d cur: %d\n", Fpos, curpos); if (UseTemp) { @@ -937,7 +937,7 @@ int DOSFAM::WriteBuffer(PGLOBAL g) return RC_FX; } // endif - if (trace) + if (trace(1)) htrc("write done\n"); return RC_OK; @@ -960,7 +960,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) /* file, and at the end erase all trailing records. */ /* This will be experimented. */ /*********************************************************************/ - if (trace) + if (trace(1)) htrc( "DOS DeleteDB: rc=%d UseTemp=%d curpos=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, curpos, Fpos, Tpos, Spos); @@ -972,7 +972,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) fseek(Stream, 0, SEEK_END); Fpos = ftell(Stream); - if (trace) + if (trace(1)) htrc("Fpos placed at file end=%d\n", Fpos); } // endif irc @@ -1015,7 +1015,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) Spos = GetNextPos(); // New start position - if (trace) + if (trace(1)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else { @@ -1058,7 +1058,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc) close(h); - if (trace) + if (trace(1)) htrc("done, h=%d irc=%d\n", h, irc); } // endif !UseTemp @@ -1083,7 +1083,7 @@ bool DOSFAM::OpenTempFile(PGLOBAL g) strcat(PlugRemoveType(tempname, tempname), ".t"); if (!(T_Stream = PlugOpenFile(g, tempname, "wb"))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); rc = true; @@ -1112,7 +1112,7 @@ bool DOSFAM::MoveIntermediateLines(PGLOBAL g, bool *b) req = (size_t)MY_MIN(n, Dbflen); len = fread(DelBuf, 1, req, Stream); - if (trace) + if (trace(1)) htrc("after read req=%d len=%d\n", req, len); if (len != req) { @@ -1131,13 +1131,13 @@ bool DOSFAM::MoveIntermediateLines(PGLOBAL g, bool *b) return true; } // endif - if (trace) + if (trace(1)) htrc("after write pos=%d\n", ftell(Stream)); Tpos += (int)req; Spos += (int)req; - if (trace) + if (trace(1)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); *b = true; @@ -1217,7 +1217,7 @@ void DOSFAM::CloseTableFile(PGLOBAL g, bool abort) } else { rc = PlugCloseFile(g, To_Fb); - if (trace) + if (trace(1)) htrc("DOS Close: closing %s rc=%d\n", To_File, rc); } // endif UseTemp @@ -1351,7 +1351,7 @@ int BLKFAM::GetPos(void) /***********************************************************************/ int BLKFAM::GetNextPos(void) { - return Fpos + NxtLine - CurLine; + return (int)(Fpos + NxtLine - CurLine); } // end of GetNextPos /***********************************************************************/ @@ -1396,7 +1396,8 @@ int BLKFAM::SkipRecord(PGLOBAL, bool header) /***********************************************************************/ int BLKFAM::ReadBuffer(PGLOBAL g) { - int i, n, rc = RC_OK; + int i, rc = RC_OK; + size_t n; /*********************************************************************/ /* Sequential reading when Placed is not true. */ @@ -1452,13 +1453,13 @@ int BLKFAM::ReadBuffer(PGLOBAL g) // Calculate the length of block to read BlkLen = BlkPos[CurBlk + 1] - BlkPos[CurBlk]; - if (trace) + if (trace(1)) htrc("File position is now %d\n", ftell(Stream)); // Read the entire next block n = fread(To_Buf, 1, (size_t)BlkLen, Stream); - if (n == BlkLen) { + if ((size_t) n == (size_t) BlkLen) { // ReadBlks++; num_read++; Rbuf = (CurBlk == Block - 1) ? Last : Nrec; @@ -1486,7 +1487,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); #endif - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return RC_FX; @@ -1497,7 +1498,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g) fin: // Store the current record file position for Delete and Update - Fpos = BlkPos[CurBlk] + CurLine - To_Buf; + Fpos = (int)(BlkPos[CurBlk] + CurLine - To_Buf); return rc; } // end of ReadBuffer @@ -1524,7 +1525,7 @@ int BLKFAM::WriteBuffer(PGLOBAL g) // Now start the writing process. NxtLine = CurLine + strlen(CurLine); - BlkLen = NxtLine - To_Buf; + BlkLen = (int)(NxtLine - To_Buf); if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) { sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); @@ -1636,7 +1637,7 @@ void BLKFAM::CloseTableFile(PGLOBAL g, bool abort) rc = PlugCloseFile(g, To_Fb); - if (trace) + if (trace(1)) htrc("BLK CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", To_File, Tdbp->GetMode(), wrc, rc); diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index 871613cb4b440c5187f00de718e21498e76e2c92..244acfdc5c87e2f133d2c9c92331cc2e7df68b9d 100755 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -336,7 +336,7 @@ int VCTFAM::Cardinality(PGLOBAL g) else sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, clen); - if (trace) + if (trace(1)) htrc(" Computed max_K=%d Filen=%d Clen=%d\n", card, len, clen); } else @@ -469,14 +469,14 @@ bool VCTFAM::OpenTableFile(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); if (!(Stream = PlugOpenFile(g, filename, opmode))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (mode == MODE_READ && errno == ENOENT) ? PushWarning(g, Tdbp) : true; } // endif Stream - if (trace) + if (trace(1)) htrc("File %s is open in mode %s\n", filename, opmode); To_Fb = dbuserp->Openlist; // Keep track of File block @@ -581,7 +581,7 @@ bool VCTFAM::InitInsert(PGLOBAL g) cp->ReadBlock(g); } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); rc = true; } catch (const char *msg) { @@ -652,7 +652,7 @@ int VCTFAM::ReadBuffer(PGLOBAL g) OldBlk = CurBlk; // Last block actually read } // endif oldblk - if (trace) + if (trace(1)) htrc(" Read: CurNum=%d CurBlk=%d rc=%d\n", CurNum, CurBlk, RC_OK); return rc; @@ -663,7 +663,7 @@ int VCTFAM::ReadBuffer(PGLOBAL g) /***********************************************************************/ int VCTFAM::WriteBuffer(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("VCT WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n", Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk); @@ -756,7 +756,7 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) { bool eof = false; - if (trace) + if (trace(1)) htrc("VCT DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, Fpos, Tpos, Spos); @@ -766,7 +766,7 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = (Block - 1) * Nrec + Last; - if (trace) + if (trace(1)) htrc("Fpos placed at file end=%d\n", Fpos); eof = UseTemp && !MaxBlk; @@ -807,7 +807,7 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) #endif Spos++; // New start position is on next line - if (trace) + if (trace(1)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else { @@ -856,7 +856,7 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc) close(h); - if (trace) + if (trace(1)) htrc("done, h=%d irc=%d\n", h, irc); } else @@ -899,7 +899,7 @@ bool VCTFAM::OpenTempFile(PGLOBAL g) opmode = "wb"; if (!(T_Stream = PlugOpenFile(g, tempname, opmode))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); rc = true; @@ -947,7 +947,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b) len = fread(To_Buf, Clens[i], req, Stream); - if (trace) + if (trace(1)) htrc("after read req=%d len=%d\n", req, len); if (len != req) { @@ -976,7 +976,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b) } // endif UseTemp - if (trace) + if (trace(1)) htrc("after write pos=%d\n", ftell(Stream)); } // endfor i @@ -1007,7 +1007,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b) } // endif UseTemp - if (trace) + if (trace(1)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); } // endfor n @@ -1144,7 +1144,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort) if (!(UseTemp && T_Stream)) rc = PlugCloseFile(g, To_Fb); - if (trace) + if (trace(1)) htrc("VCT CloseTableFile: closing %s wrc=%d rc=%d\n", To_File, wrc, rc); @@ -1217,7 +1217,7 @@ bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) else // Blocked vector format len = Nrec * (colp->Deplac + Lrecl * CurBlk); - if (trace) + if (trace(1)) htrc("len=%d Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d maxblk=%d\n", len, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk); @@ -1236,13 +1236,13 @@ bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno)); - if (trace) + if (trace(1)) htrc(" Read error: %s\n", g->Message); return true; } // endif - if (trace) + if (trace(1)) num_read++; return false; @@ -1268,7 +1268,7 @@ bool VCTFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) else // Old VCT format len = Nrec * (colp->Deplac + Lrecl * colp->ColBlk); - if (trace) + if (trace(1)) htrc("modif=%d len=%d Nrec=%d Deplac=%d Lrecl=%d colblk=%d\n", Modif, len, Nrec, colp->Deplac, Lrecl, colp->ColBlk); @@ -1287,7 +1287,7 @@ bool VCTFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) sprintf(g->Message, MSG(WRITE_STRERROR), (UseTemp) ? To_Fbt->Fname : To_File, strerror(errno)); - if (trace) + if (trace(1)) htrc("Write error: %s\n", strerror(errno)); return true; @@ -1358,7 +1358,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) && fp->Count && fp->Mode == mode) break; - if (trace) + if (trace(1)) htrc("Mapping VCM file, fp=%p cnt=%d\n", fp, fp->Count); } else @@ -1416,7 +1416,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int) rc, filename); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (mode == MODE_READ && rc == ENOENT) @@ -1467,7 +1467,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) To_Fb = fp; // Useful when closing - if (trace) + if (trace(1)) htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n", fp, fp->Count, Memory, len); @@ -1551,7 +1551,7 @@ bool VCMFAM::InitInsert(PGLOBAL g) cp->ReadBlock(g); } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); rc = true; } catch (const char *msg) { @@ -1567,7 +1567,7 @@ bool VCMFAM::InitInsert(PGLOBAL g) /***********************************************************************/ int VCMFAM::WriteBuffer(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("VCM WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n", Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk); @@ -1608,7 +1608,7 @@ int VCMFAM::WriteBuffer(PGLOBAL g) /***********************************************************************/ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) { - if (trace) + if (trace(1)) htrc("VCM DeleteDB: irc=%d tobuf=%p Tpos=%p Spos=%p\n", irc, To_Buf, Tpos, Spos); @@ -1618,7 +1618,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = (Block - 1) * Nrec + Last; - if (trace) + if (trace(1)) htrc("Fpos placed at file top=%p\n", Fpos); } else // Fpos is the Deleted line position @@ -1636,7 +1636,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) if (irc == RC_OK) { Spos = Fpos + 1; // New start position - if (trace) + if (trace(1)) htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); } else { @@ -1680,7 +1680,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc) return RC_FX; } // endif - if (trace) + if (trace(1)) htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); if (!SetEndOfFile(fp->Handle)) { @@ -1755,7 +1755,7 @@ bool VCMFAM::MoveIntermediateLines(PGLOBAL, bool *) Tpos += n; } // endif MaxBlk - if (trace) + if (trace(1)) htrc("move %d bytes\n", n); } // endif n @@ -1812,14 +1812,14 @@ bool VCMFAM::ReadBlock(PGLOBAL, PVCTCOL colp) /*********************************************************************/ mempos = Memcol[i] + n * CurBlk; - if (trace) + if (trace(1)) htrc("mempos=%p i=%d Nrec=%d Clen=%d CurBlk=%d\n", mempos, i, Nrec, colp->Clen, CurBlk); if (colp->GetStatus(BUF_MAPPED)) colp->Blk->SetValPointer(mempos); - if (trace) + if (trace(1)) num_read++; return false; @@ -1843,7 +1843,7 @@ bool VCMFAM::WriteBlock(PGLOBAL, PVCTCOL colp __attribute__((unused))) /*********************************************************************/ mempos = Memcol[i] + n * CurBlk; - if (trace) + if (trace(1)) htrc("modif=%d mempos=%p i=%d Nrec=%d Clen=%d colblk=%d\n", Modif, mempos, i, Nrec, colp->Clen, colp->ColBlk); @@ -2008,14 +2008,14 @@ bool VECFAM::OpenColumnFile(PGLOBAL g, PCSZ opmode, int i) sprintf(filename, Colfn, i+1); if (!(Streams[i] = PlugOpenFile(g, filename, opmode))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (Tdbp->GetMode() == MODE_READ && errno == ENOENT) ? PushWarning(g, Tdbp) : true; } // endif Streams - if (trace) + if (trace(1)) htrc("File %s is open in mode %s\n", filename, opmode); To_Fbs[i] = dup->Openlist; // Keep track of File blocks @@ -2163,7 +2163,7 @@ void VECFAM::ResetBuffer(PGLOBAL g) /***********************************************************************/ int VECFAM::WriteBuffer(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("VCT WriteBuffer: R%d Mode=%d CurNum=%d CurBlk=%d\n", Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk); @@ -2205,7 +2205,7 @@ int VECFAM::WriteBuffer(PGLOBAL g) /***********************************************************************/ int VECFAM::DeleteRecords(PGLOBAL g, int irc) { - if (trace) + if (trace(1)) htrc("VEC DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, Fpos, Tpos, Spos); @@ -2215,7 +2215,7 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = Cardinality(g); - if (trace) + if (trace(1)) htrc("Fpos placed at file end=%d\n", Fpos); } else // Fpos is the Deleted line position @@ -2251,7 +2251,7 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc) #endif Spos++; // New start position is on next line - if (trace) + if (trace(1)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else { @@ -2294,7 +2294,7 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc) close(h); - if (trace) + if (trace(1)) htrc("done, h=%d irc=%d\n", h, irc); } // endfor i @@ -2332,7 +2332,7 @@ bool VECFAM::OpenTempFile(PGLOBAL g) sprintf(tempname, Tempat, i+1); if (!(T_Streams[i] = PlugOpenFile(g, tempname, "wb"))) { - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return true; @@ -2391,7 +2391,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *) len = fread(To_Buf, Clens[i], req, Streams[i]); - if (trace) + if (trace(1)) htrc("after read req=%d len=%d\n", req, len); if (len != req) { @@ -2410,7 +2410,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *) return true; } // endif - if (trace) + if (trace(1)) htrc("after write pos=%d\n", ftell(Streams[i])); } // endfor i @@ -2418,7 +2418,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *) Tpos += (int)req; Spos += (int)req; - if (trace) + if (trace(1)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); b = true; @@ -2541,7 +2541,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort) To_Fbs[i] = NULL; } // endif Streams - if (trace) + if (trace(1)) htrc("VCT CloseTableFile: closing %s wrc=%d rc=%d\n", To_File, wrc, rc); } // end of CloseTableFile @@ -2560,7 +2560,7 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) len = Nrec * colp->Clen * CurBlk; i = colp->Index - 1; - if (trace) + if (trace(1)) htrc("len=%d i=%d Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d\n", len, i, Nrec, colp->Deplac, Lrecl, CurBlk); @@ -2586,13 +2586,13 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) sprintf(g->Message, MSG(READ_ERROR), fn, strerror(errno)); - if (trace) + if (trace(1)) htrc(" Read error: %s\n", g->Message); return true; } // endif - if (trace) + if (trace(1)) num_read++; return false; @@ -2615,7 +2615,7 @@ bool VECFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) len = Nrec * colp->Clen * colp->ColBlk; i = colp->Index - 1; - if (trace) + if (trace(1)) htrc("modif=%d len=%d i=%d Nrec=%d Deplac=%d Lrecl=%d colblk=%d\n", Modif, len, i, Nrec, colp->Deplac, Lrecl, colp->ColBlk); @@ -2638,7 +2638,7 @@ bool VECFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) sprintf(fn, (UseTemp) ? Tempat : Colfn, colp->Index); sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); - if (trace) + if (trace(1)) htrc("Write error: %s\n", strerror(errno)); return true; @@ -2782,7 +2782,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) && fp->Count && fp->Mode == mode) break; - if (trace) + if (trace(1)) htrc("Mapping file, fp=%p\n", fp); } else @@ -2807,7 +2807,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) if (!(*g->Message)) sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int) rc, filename); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return (mode == MODE_READ && rc == ENOENT) @@ -2858,7 +2858,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) To_Fbs[i] = fp; // Useful when closing - if (trace) + if (trace(1)) htrc("fp=%p count=%d MapView=%p len=%d\n", fp, fp->Count, Memcol[i], len); @@ -2903,7 +2903,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) int i; int m, n; - if (trace) + if (trace(1)) htrc("VMP DeleteDB: irc=%d tobuf=%p Tpos=%p Spos=%p\n", irc, To_Buf, Tpos, Spos); @@ -2913,7 +2913,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = (Block - 1) * Nrec + Last; - if (trace) + if (trace(1)) htrc("Fpos placed at file top=%p\n", Fpos); } else // Fpos is the Deleted line position @@ -2936,7 +2936,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) Tpos += n; - if (trace) + if (trace(1)) htrc("move %d bytes\n", n); } // endif n @@ -2944,7 +2944,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) if (irc == RC_OK) { Spos = Fpos + 1; // New start position - if (trace) + if (trace(1)) htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); } else { @@ -2981,7 +2981,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc) return RC_FX; } // endif - if (trace) + if (trace(1)) htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); if (!SetEndOfFile(fp->Handle)) { @@ -3088,7 +3088,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) DWORD nbr, drc, len = (DWORD)req; bool brc = ReadFile(h, inbuf, len, &nbr, NULL); - if (trace) + if (trace(1)) htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr); if (!brc || nbr != len) { @@ -3105,7 +3105,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(READ_ERROR), To_File, buf); - if (trace) + if (trace(1)) htrc("BIGREAD: %s\n", g->Message); rc = true; @@ -3119,7 +3119,7 @@ bool BGVFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(READ_ERROR), fn, strerror(errno)); - if (trace) + if (trace(1)) htrc("BIGREAD: nbr=%d len=%d errno=%d %s\n", nbr, len, errno, g->Message); @@ -3141,7 +3141,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) DWORD nbw, drc, len = (DWORD)req; bool brc = WriteFile(h, inbuf, len, &nbw, NULL); - if (trace) + if (trace(1)) htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw); if (!brc || nbw != len) { @@ -3159,7 +3159,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf); - if (trace) + if (trace(1)) htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", nbw, len, drc, g->Message); @@ -3174,7 +3174,7 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req) sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno)); - if (trace) + if (trace(1)) htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n", nbw, len, errno, g->Message); @@ -3224,7 +3224,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) if (h == INVALID_HANDLE_VALUE || !_filelength(h)) { #endif // !__WIN__ // Consider this is a void table - if (trace) + if (trace(1)) htrc("Void table h=%d\n", h); Last = Nrec; @@ -3248,7 +3248,7 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) Block = (vh.NumRec > 0) ? (vh.NumRec + Nrec - 1) / Nrec : 0; Last = (vh.NumRec + Nrec - 1) % Nrec + 1; - if (trace) + if (trace(1)) htrc("Block=%d Last=%d\n", Block, Last); } // endif's @@ -3348,7 +3348,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn) of.QuadPart = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1; - if (trace) + if (trace(1)) htrc("MEF: of=%lld n=%d maxblk=%d blksize=%d\n", of.QuadPart, n, MaxBlk, Blksize); @@ -3394,7 +3394,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn) pos = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1; - if (trace) + if (trace(1)) htrc("MEF: pos=%lld n=%d maxblk=%d blksize=%d\n", pos, n, MaxBlk, Blksize); @@ -3439,7 +3439,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) PlugSetPath(filename, To_File, Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("OpenTableFile: filename=%s mode=%d Last=%d\n", filename, mode, Last); @@ -3516,7 +3516,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) strcat(g->Message, filename); } // endif Hfile - if (trace) + if (trace(1)) htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n", rc, access, share, creation, Hfile, filename); @@ -3605,7 +3605,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) strcat(g->Message, strerror(errno)); } // endif Hfile - if (trace) + if (trace(1)) htrc(" rc=%d oflag=%p mode=%p handle=%d fn=%s\n", rc, oflag, mode, Hfile, filename); #endif // UNIX @@ -3626,7 +3626,7 @@ bool BGVFAM::OpenTableFile(PGLOBAL g) To_Fb->Mode = mode; To_Fb->Handle = Hfile; - if (trace) + if (trace(1)) htrc("File %s is open in mode %d\n", filename, mode); if (del) @@ -3729,7 +3729,7 @@ bool BGVFAM::AllocateBuffer(PGLOBAL g) /***********************************************************************/ int BGVFAM::WriteBuffer(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("BGV WriteDB: R%d Mode=%d CurNum=%d CurBlk=%d\n", Tdbp->GetTdb_No(), Tdbp->GetMode(), CurNum, CurBlk); @@ -3829,7 +3829,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) /* 2 - directly move the not deleted lines inside the original */ /* file, and at the end erase all trailing records. */ /*********************************************************************/ - if (trace) + if (trace(1)) htrc("BGV DeleteDB: irc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n", irc, UseTemp, Fpos, Tpos, Spos); @@ -3839,7 +3839,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) /*******************************************************************/ Fpos = (Block - 1) * Nrec + Last; - if (trace) + if (trace(1)) htrc("Fpos placed at file end=%d\n", Fpos); eof = UseTemp && !MaxBlk; @@ -3878,7 +3878,7 @@ int BGVFAM::DeleteRecords(PGLOBAL g, int irc) #endif Spos++; // New start position is on next line - if (trace) + if (trace(1)) htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos); } else { @@ -4065,7 +4065,7 @@ bool BGVFAM::MoveIntermediateLines(PGLOBAL g, bool *b) } // endif Usetemp... - if (trace) + if (trace(1)) htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos); } // endfor n @@ -4201,7 +4201,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort) if (Hfile != INVALID_HANDLE_VALUE) rc = PlugCloseFile(g, To_Fb); - if (trace) + if (trace(1)) htrc("BGV CloseTableFile: closing %s wrc=%d rc=%d\n", To_File, wrc, rc); @@ -4247,7 +4247,7 @@ bool BGVFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac + (BIGINT)Lrecl * (BIGINT)CurBlk); - if (trace) + if (trace(1)) htrc("RB: offset=%lld Nrec=%d Deplac=%d Lrecl=%d CurBlk=%d MaxBlk=%d\n", pos, Nrec, colp->Deplac, Lrecl, CurBlk, MaxBlk); @@ -4257,7 +4257,7 @@ bool BGVFAM::ReadBlock(PGLOBAL g, PVCTCOL colp) if (BigRead(g, Hfile, colp->Blk->GetValPointer(), colp->Clen * Nrec)) return true; - if (trace) + if (trace(1)) num_read++; return false; @@ -4284,7 +4284,7 @@ bool BGVFAM::WriteBlock(PGLOBAL g, PVCTCOL colp) pos = (BIGINT)Nrec * ((BIGINT)colp->Deplac + (BIGINT)Lrecl * (BIGINT)colp->ColBlk); - if (trace) + if (trace(1)) htrc("WB: offset=%lld Nrec=%d Deplac=%d Lrecl=%d ColBlk=%d\n", pos, Nrec, colp->Deplac, Lrecl, colp->ColBlk); diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index dfd9343af76ca260b94b980409d43bd2b6785902..e76dc496246631f5925fe9c02073bf4b7e8b6807 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -699,7 +699,7 @@ bool UNZIPUTL::openEntry(PGLOBAL g) entryopen = true; } // endif rc - if (trace) + if (trace(1)) htrc("Openning entry%s %s\n", fn, (entryopen) ? "oked" : "failed"); return !entryopen; @@ -748,10 +748,10 @@ UNZFAM::UNZFAM(PUNZFAM txfp) : MAPFAM(txfp) /***********************************************************************/ int UNZFAM::GetFileLength(PGLOBAL g) { - int len = (zutp && zutp->entryopen) ? Top - Memory + int len = (zutp && zutp->entryopen) ? (int)(Top - Memory) : TXTFAM::GetFileLength(g) * 3; - if (trace) + if (trace(1)) htrc("Zipped file length=%d\n", len); return len; @@ -1088,7 +1088,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g) // Prepare to write the new line strcat(strcpy(To_Buf, Tdbp->GetLine()), (Bin) ? CrLf : "\n"); - len = strchr(To_Buf, '\n') - To_Buf + 1; + len = (int)(strchr(To_Buf, '\n') - To_Buf + 1); return zutp->writeEntry(g, To_Buf, len); } // end of WriteBuffer diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 079128f9aa63a976f40967a1a2833fd116111156..469cd90d1d7cb81e27e2574f6d3cf38952c04ee6 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -87,7 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc) case OP_EXIST: bt = 0x00; break; default: sprintf(g->Message, MSG(BAD_FILTER_OP), opc); - throw (int)TYPE_ARRAY; + throw (int)TYPE_FILTER; } // endswitch opc return bt; @@ -301,7 +301,7 @@ PFIL FILTER::Link(PGLOBAL g, PFIL fil2) { PFIL fil1; - if (trace) + if (trace(1)) htrc("Linking filter %p with op=%d... to filter %p with op=%d\n", this, Opc, fil2, (fil2) ? fil2->Opc : 0); @@ -355,7 +355,7 @@ int FILTER::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag) char errmsg[MAX_STR] = ""; int agg, k, n = 0; - if (trace) + if (trace(1)) htrc("FILTER CheckColumn: sqlp=%p ag=%d\n", sqlp, ag); switch (Opc) { @@ -540,7 +540,7 @@ PFIL FILTER::SortJoin(PGLOBAL g) bool FILTER::FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq, bool tek, bool tk2, bool tc2, bool tix, bool thx) { - if (trace) + if (trace(1)) htrc("FindJoinFilter: opj=%p fprec=%p tests=(%d,%d,%d,%d)\n", opj, fprec, teq, tek, tk2, tc2); @@ -867,7 +867,7 @@ bool FILTER::CheckLocal(PTDB tdbp) { bool local = TRUE; - if (trace) { + if (trace(1)) { if (tdbp) htrc("CheckLocal: filp=%p R%d\n", this, tdbp->GetTdb_No()); else @@ -877,7 +877,7 @@ bool FILTER::CheckLocal(PTDB tdbp) for (int i = 0; local && i < 2; i++) local = Arg(i)->CheckLocal(tdbp); - if (trace) + if (trace(1)) htrc("FCL: returning %d\n", local); return (local); @@ -983,7 +983,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) { int i, comtype = TYPE_ERROR; - if (trace) + if (trace(1)) htrc("converting(?) %s %p opc=%d\n", (having) ? "having" : "filter", this, Opc); @@ -1014,7 +1014,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) return TRUE; } // endswitch - if (trace) + if (trace(1)) htrc("Filter(%d): Arg type=%d\n", i, GetArgType(i)); // Set default values @@ -1059,7 +1059,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) return TRUE; } // endif - if (trace) + if (trace(1)) htrc(" comtype=%d, B_T(%d)=%d Val(%d)=%p\n", comtype, i, Test[i].B_T, i, Val(i)); @@ -1067,7 +1067,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) // Set or allocate the filter argument values and buffers for (i = 0; i < 2; i++) { - if (trace) + if (trace(1)) htrc(" conv type %d ? i=%d B_T=%d comtype=%d\n", GetArgType(i), i, Test[i].B_T, comtype); @@ -1144,7 +1144,7 @@ bool FILTER::Convert(PGLOBAL g, bool having) TEST: // Test for possible Eval optimization - if (trace) + if (trace(1)) htrc("Filp %p op=%d argtypes=(%d,%d)\n", this, Opc, GetArgType(0), GetArgType(1)); @@ -1233,7 +1233,7 @@ bool FILTER::Eval(PGLOBAL g) else if (Test[i].Conv) Val(i)->SetValue_pval(Arg(i)->GetValue()); - if (trace) + if (trace(1)) htrc(" Filter: op=%d type=%d %d B_T=%d %d val=%p %p\n", Opc, GetArgType(0), GetArgType(1), Test[0].B_T, Test[1].B_T, Val(0), Val(1)); @@ -1273,7 +1273,7 @@ bool FILTER::Eval(PGLOBAL g) goto FilterError; } // endswitch Type - if (trace) { + if (trace(1)) { htrc(" IN filtering: ap=%p\n", ap); if (ap) @@ -1363,7 +1363,7 @@ bool FILTER::Eval(PGLOBAL g) goto FilterError; } // endswitch Opc - if (trace) + if (trace(1)) htrc("Eval: filter %p Opc=%d result=%d\n", this, Opc, Value->GetIntValue()); @@ -1775,7 +1775,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) { PFIL filp = NULL; - if (trace) + if (trace(1)) htrc("PrepareFilter: fp=%p having=%d\n", fp, having); while (fp) { @@ -1790,14 +1790,14 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) break; // Remove eventual ending separator(s) // if (fp->Convert(g, having)) -// (int)throw TYPE_ARRAY; +// throw (int)TYPE_FILTER; filp = fp; fp = fp->Next; filp->Next = NULL; } // endwhile - if (trace) + if (trace(1)) htrc(" returning filp=%p\n", filp); return filp; @@ -1823,7 +1823,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp) if (filp->Eval(g)) throw (int)TYPE_FILTER; - if (trace > 1) + if (trace(2)) htrc("PlugFilter filp=%p result=%d\n", filp, filp->GetResult()); diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index a8d48a5d3b1deb8730f80705f7e36a969472b1b6..729b1b883c17197450231379bd71d5146b5e5cb6 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -283,7 +283,7 @@ static void yy_fatal_error YY_PROTO(( const char msg[] )); */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ - yyleng = yy_cp - yy_bp; \ + yyleng = (int)(yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; @@ -695,7 +695,7 @@ case YY_STATE_EOF(dqt): case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1; + int yy_amount_of_matched_text = (int)(yy_cp - yytext_ptr - 1); /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; @@ -862,7 +862,7 @@ static int yy_get_next_buffer() /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = yy_c_buf_p - yytext_ptr; + number_to_move = (int)(yy_c_buf_p - yytext_ptr); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -888,7 +888,7 @@ static int yy_get_next_buffer() /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; - int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf; + int yy_c_buf_p_offset = (int)(yy_c_buf_p - b->yy_ch_buf); b->yy_buf_size *= 2; b->yy_ch_buf = (char *) diff --git a/storage/connect/global.h b/storage/connect/global.h index e4b00786efa795a53776a3d7994c60633a42be6c..472d09408c3eea2c537e602aa87a7457af8a0c6e 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -52,7 +52,7 @@ /***********************************************************************/ /* Define access to the thread based trace value. */ /***********************************************************************/ -#define trace GetTraceValue() +#define trace(T) (bool)(GetTraceValue() & (uint)T) /***********************************************************************/ /* Miscellaneous Constants */ @@ -220,14 +220,19 @@ DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport bool AllocSarea(PGLOBAL, uint); DllExport void FreeSarea(PGLOBAL); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); -DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport void *MakePtr(void *, OFFSET); DllExport void htrc(char const *fmt, ...); -DllExport int GetTraceValue(void); +//DllExport int GetTraceValue(void); +DllExport uint GetTraceValue(void); #if defined(__cplusplus) } // extern "C" #endif +/***********************************************************************/ +/* Non exported routine declarations. */ +/***********************************************************************/ +void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw + /*-------------------------- End of Global.H --------------------------*/ diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 5964b1d049f4ae127a4c258b5cf414110179a0b0..af329c0c8df694a96e64b0eb6ad6bc2791b14317 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -98,8 +98,8 @@ rnd_next signals that it has reached the end of its data. Calls to ha_connect::extra() are hints as to what will be occuring to the request. - Author Olivier Bertrand -*/ + Author Olivier Bertrand + */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation @@ -174,9 +174,9 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.06.0005 October 14, 2017"; + char version[]= "Version 1.06.0007 March 11, 2018"; #if defined(__WIN__) - char compver[]= "Version 1.06.0005 " __DATE__ " " __TIME__; + char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -266,16 +266,38 @@ static char *strz(PGLOBAL g, LEX_STRING &ls) /***********************************************************************/ /* CONNECT session variables definitions. */ /***********************************************************************/ -// Tracing: 0 no, 1 yes, >1 more tracing -static MYSQL_THDVAR_INT(xtrace, - PLUGIN_VAR_RQCMDARG, "Console trace value.", - NULL, NULL, 0, 0, INT_MAX, 1); +// Tracing: 0 no, 1 yes, 2 more, 4 index... 511 all +const char *xtrace_names[] = +{ + "YES", "MORE", "INDEX", "MEMORY", "SUBALLOC", + "QUERY", "STMT", "HANDLER", "BLOCK", "MONGO", NullS +}; + +TYPELIB xtrace_typelib = +{ + array_elements(xtrace_names) - 1, "xtrace_typelib", + xtrace_names, NULL +}; + +static MYSQL_THDVAR_SET( + xtrace, // name + PLUGIN_VAR_RQCMDARG, // opt + "Trace values.", // comment + NULL, // check + NULL, // update function + 0, // def (NO) + &xtrace_typelib); // typelib // Getting exact info values static MYSQL_THDVAR_BOOL(exact_info, PLUGIN_VAR_RQCMDARG, "Getting exact info values", NULL, NULL, 0); +// Enabling cond_push +static MYSQL_THDVAR_BOOL(cond_push, PLUGIN_VAR_RQCMDARG, + "Enabling cond_push", + NULL, NULL, 1); // YES by default + /** Temporary file usage: no: Not using temporary file @@ -314,17 +336,18 @@ static MYSQL_THDVAR_UINT(work_size, static MYSQL_THDVAR_INT(conv_size, PLUGIN_VAR_RQCMDARG, // opt "Size used when converting TEXT columns.", - NULL, NULL, SZCONV, 0, 65500, 1); + NULL, NULL, SZCONV, 0, 65500, 8192); /** Type conversion: no: Unsupported types -> TYPE_ERROR yes: TEXT -> VARCHAR + force: Do it also for ODBC BINARY and BLOBs skip: skip unsupported type columns in Discovery */ const char *xconv_names[]= { - "NO", "YES", "SKIP", NullS + "NO", "YES", "FORCE", "SKIP", NullS }; TYPELIB xconv_typelib= @@ -339,7 +362,7 @@ static MYSQL_THDVAR_ENUM( "Unsupported types conversion.", // comment NULL, // check NULL, // update function - 0, // def (no) + 1, // def (yes) &xconv_typelib); // typelib // Null representation for JSON values @@ -364,12 +387,17 @@ static MYSQL_THDVAR_STR(java_wrapper, NULL, NULL, "wrappers/JdbcInterface"); #endif // JAVA_SUPPORT -#if 0 // This is apparently not acceptable for a plugin +// This is apparently not acceptable for a plugin so it is undocumented +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) // Enabling MONGO table type +#if defined(MONGO_SUPPORT) || (MYSQL_VERSION_ID > 100200) static MYSQL_THDVAR_BOOL(enable_mongo, PLUGIN_VAR_RQCMDARG, - "Enabling the MongoDB access", - NULL, NULL, MONGO_ENABLED); -#endif // 0 + "Enabling the MongoDB access", NULL, NULL, 1); +#else // !version 2,3 +static MYSQL_THDVAR_BOOL(enable_mongo, PLUGIN_VAR_RQCMDARG, + "Enabling the MongoDB access", NULL, NULL, 0); +#endif // !version 2,3 +#endif // JAVA_SUPPORT || CMGO_SUPPORT #if defined(XMSG) || defined(NEWMSG) const char *language_names[]= @@ -401,9 +429,10 @@ handlerton *connect_hton= NULL; /***********************************************************************/ /* Function to export session variable values to other source files. */ /***********************************************************************/ -extern "C" int GetTraceValue(void) - {return connect_hton ? THDVAR(current_thd, xtrace) : 0;} +uint GetTraceValue(void) + {return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);} bool ExactInfo(void) {return THDVAR(current_thd, exact_info);} +static bool CondPushEnabled(void) {return THDVAR(current_thd, cond_push);} USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);} int GetConvSize(void) {return THDVAR(current_thd, conv_size);} TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);} @@ -419,22 +448,20 @@ void SetWorkSize(uint) push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, "Work size too big, try setting a smaller value"); } // end of SetWorkSize -#if defined(XMSG) || defined(NEWMSG) -extern "C" const char *msglang(void) -{ - return language_names[THDVAR(current_thd, msg_lang)]; -} // end of msglang -#else // !XMSG && !NEWMSG #if defined(JAVA_SUPPORT) char *GetJavaWrapper(void) {return connect_hton ? THDVAR(current_thd, java_wrapper) : (char*)"wrappers/JdbcInterface";} #endif // JAVA_SUPPORT -#if defined(JAVA_SUPPORT) -//bool MongoEnabled(void) { return THDVAR(current_thd, enable_mongo); } -#endif // JAVA_SUPPORT +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) +bool MongoEnabled(void) {return THDVAR(current_thd, enable_mongo);} +#endif // JAVA_SUPPORT || CMGO_SUPPORT +#if defined(XMSG) || defined(NEWMSG) +extern "C" const char *msglang(void) + {return language_names[THDVAR(current_thd, msg_lang)];} +#else // !XMSG && !NEWMSG extern "C" const char *msglang(void) { #if defined(FRENCH) @@ -726,7 +753,7 @@ static int connect_init_func(void *p) connect_hton->tablefile_extensions= ha_connect_exts; connect_hton->discover_table_structure= connect_assisted_discovery; - if (trace) + if (trace(128)) sql_print_information("connect_init: hton=%p", p); DTVAL::SetTimeShift(); // Initialize time zone shift once for all @@ -818,7 +845,7 @@ static handler* connect_create_handler(handlerton *hton, { handler *h= new (mem_root) ha_connect(hton, table); - if (trace) + if (trace(128)) htrc("New CONNECT %p, table: %.*s\n", h, table ? table->table_name.length : 6, table ? table->table_name.str : ""); @@ -874,7 +901,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) /****************************************************************************/ ha_connect::~ha_connect(void) { - if (trace) + if (trace(128)) htrc("Delete CONNECT %p, table: %.*s, xp=%p count=%d\n", this, table ? table->s->table_name.length : 6, table ? table->s->table_name.str : "", @@ -1086,55 +1113,55 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def) if (!oplist) return (char*)def; - char key[16], val[256]; - char *pv, *pn, *pk= (char*)oplist; - PCSZ opval= def; - int n; + char key[16], val[256]; + char *pv, *pn, *pk = (char*)oplist; + PCSZ opval = def; + int n; while (*pk == ' ') pk++; - for (; pk; pk= pn) { - pn= strchr(pk, ','); - pv= strchr(pk, '='); + for (; pk; pk = pn) { + pn = strchr(pk, ','); + pv = strchr(pk, '='); - if (pv && (!pn || pv < pn)) { + if (pv && (!pn || pv < pn)) { n = MY_MIN(static_cast(pv - pk), sizeof(key) - 1); memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n]= 0; + key[n] = 0; - while(*(++pv) == ' ') ; + while (*(++pv) == ' '); - n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); - memcpy(val, pv, n); + n = MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); + memcpy(val, pv, n); while (n && val[n - 1] == ' ') n--; - val[n]= 0; - } else { - n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); - memcpy(key, pk, n); + val[n] = 0; + } else { + n = MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); + memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n]= 0; - val[0]= 0; - } // endif pv + key[n] = 0; + val[0] = 0; + } // endif pv - if (!stricmp(opname, key)) { - opval= PlugDup(g, val); - break; - } else if (!pn) - break; + if (!stricmp(opname, key)) { + opval = PlugDup(g, val); + break; + } else if (!pn) + break; - while (*(++pn) == ' ') ; - } // endfor pk + while (*(++pn) == ' '); + } // endfor pk return opval; } // end of GetListOption @@ -1658,7 +1685,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s) s= table->s; for (int n= 0; (unsigned)n < s->keynames.count; n++) { - if (trace) + if (trace(1)) htrc("Getting created index %d info\n", n + 1); // Find the index to describe @@ -1754,11 +1781,13 @@ bool ha_connect::CheckVirtualIndex(TABLE_SHARE *s) bool ha_connect::IsPartitioned(void) { +#ifdef WITH_PARTITION_STORAGE_ENGINE if (tshp) return tshp->partition_info_str_len > 0; else if (table && table->part_info) return true; else +#endif return false; } // end of IsPartitioned @@ -2004,7 +2033,7 @@ bool ha_connect::CheckColumnList(PGLOBAL g) } // endif } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); brc = true; } catch (const char *msg) { @@ -2061,7 +2090,7 @@ int ha_connect::MakeRecord(char *buf) PCOL colp= NULL; DBUG_ENTER("ha_connect::MakeRecord"); - if (trace > 1) + if (trace(2)) htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n", *table->read_set->bitmap, *table->write_set->bitmap, (table->vcol_set) ? *table->vcol_set->bitmap : 0, @@ -2585,14 +2614,14 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) if (!cond) return NULL; - if (trace) + if (trace(1)) htrc("Cond type=%d\n", cond->type()); if (cond->type() == COND::COND_ITEM) { PFIL fp; Item_cond *cond_item= (Item_cond *)cond; - if (trace) + if (trace(1)) htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(), cond_item->func_name()); @@ -2626,7 +2655,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) Item_func *condf= (Item_func *)cond; Item* *args= condf->arguments(); - if (trace) + if (trace(1)) htrc("Func type=%d argnum=%d\n", condf->functype(), condf->argument_count()); @@ -2655,11 +2684,11 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) return NULL; for (i= 0; i < condf->argument_count(); i++) { - if (trace) + if (trace(1)) htrc("Argtype(%d)=%d\n", i, args[i]->type()); if (i >= 2 && !ismul) { - if (trace) + if (trace(1)) htrc("Unexpected arg for vop=%d\n", vop); continue; @@ -2689,7 +2718,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) break; } // endswitch type - if (trace) { + if (trace(1)) { htrc("Field index=%d\n", pField->field->field_index); htrc("Field name=%s\n", pField->field->field_name); } // endif trace @@ -2736,7 +2765,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) return NULL; } // endswitch type - if (trace) + if (trace(1)) htrc("Value type=%hd\n", pp->Type); // Append the value to the argument list @@ -2754,7 +2783,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) filp= MakeFilter(g, colp, pop, pfirst, neg); } else { - if (trace) + if (trace(1)) htrc("Unsupported condition\n"); return NULL; @@ -2780,7 +2809,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) if (!cond) return NULL; - if (trace) + if (trace(1)) htrc("Cond type=%d\n", cond->type()); if (cond->type() == COND::COND_ITEM) { @@ -2793,7 +2822,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) else pb0= pb1= pb2= ph0= ph1= ph2= NULL; - if (trace) + if (trace(1)) htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(), cond_item->func_name()); @@ -2879,7 +2908,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) filp->Bd = filp->Hv = false; - if (trace) + if (trace(1)) htrc("Func type=%d argnum=%d\n", condf->functype(), condf->argument_count()); @@ -2916,11 +2945,11 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) return NULL; for (i= 0; i < condf->argument_count(); i++) { - if (trace) + if (trace(1)) htrc("Argtype(%d)=%d\n", i, args[i]->type()); if (i >= 2 && !ismul) { - if (trace) + if (trace(1)) htrc("Unexpected arg for vop=%d\n", vop); continue; @@ -2963,7 +2992,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) } // endif's - if (trace) { + if (trace(1)) { htrc("Field index=%d\n", pField->field->field_index); htrc("Field name=%s\n", pField->field->field_name); htrc("Field type=%d\n", pField->field->type()); @@ -3001,7 +3030,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) if ((res= pval->val_str(&tmp)) == NULL) return NULL; // To be clarified - if (trace) + if (trace(1)) htrc("Value=%.*s\n", res->length(), res->ptr()); // IN and BETWEEN clauses should be col VOP list @@ -3142,7 +3171,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) filp->Bd = true; } else { - if (trace) + if (trace(1)) htrc("Unsupported condition\n"); return NULL; @@ -3175,7 +3204,7 @@ const COND *ha_connect::cond_push(const COND *cond) { DBUG_ENTER("ha_connect::cond_push"); - if (tdbp) { + if (tdbp && CondPushEnabled()) { PGLOBAL& g= xp->g; AMT tty= tdbp->GetAmType(); bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC); @@ -3209,7 +3238,7 @@ const COND *ha_connect::cond_push(const COND *cond) if (filp->Having && strlen(filp->Having) > 255) goto fin; // Memory collapse - if (trace) + if (trace(1)) htrc("cond_push: %s\n", filp->Body); tdbp->SetCond(cond); @@ -3235,7 +3264,7 @@ const COND *ha_connect::cond_push(const COND *cond) } // endif tty } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); } catch (const char *msg) { strcpy(g->Message, msg); @@ -3288,7 +3317,7 @@ bool ha_connect::get_error_message(int error, String* buf) &my_charset_latin1, &dummy_errors); - if (trace) + if (trace(1)) htrc("GEM(%d): len=%u %s\n", error, len, g->Message); msg[len]= '\0'; @@ -3340,7 +3369,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) int rc= 0; DBUG_ENTER("ha_connect::open"); - if (trace) + if (trace(1)) htrc("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked); if (!(share= get_share())) @@ -3415,7 +3444,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) rc = HA_ERR_INTERNAL_ERROR; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); rc = HA_ERR_INTERNAL_ERROR; } catch (const char *msg) { @@ -3563,7 +3592,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data) PGLOBAL& g= xp->g; DBUG_ENTER("ha_connect::update_row"); - if (trace > 1) + if (trace(2)) htrc("update_row: old=%s new=%s\n", old_data, new_data); // Check values for possible change in indexed column @@ -3624,7 +3653,7 @@ int ha_connect::index_init(uint idx, bool sorted) PGLOBAL& g= xp->g; DBUG_ENTER("index_init"); - if (trace) + if (trace(1)) htrc("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted); if (GetIndexType(GetRealType()) == 2) { @@ -3677,7 +3706,7 @@ int ha_connect::index_init(uint idx, bool sorted) rc= 0; } // endif indexing - if (trace) + if (trace(1)) htrc("index_init: rc=%d indexing=%d active_index=%d\n", rc, indexing, active_index); @@ -3724,7 +3753,7 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const key_range *kr) break; } // endswitch RC - if (trace > 1) + if (trace(2)) htrc("ReadIndexed: op=%d rc=%d\n", op, rc); table->status= (rc == RC_OK) ? 0 : STATUS_NOT_FOUND; @@ -3767,7 +3796,7 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len, default: DBUG_RETURN(-1); break; } // endswitch find_flag - if (trace > 1) + if (trace(2)) htrc("%p index_read: op=%d\n", this, op); if (indexing > 0) { @@ -3931,7 +3960,7 @@ int ha_connect::rnd_init(bool scan) alter= 1; } // endif xmod - if (trace) + if (trace(1)) htrc("rnd_init: this=%p scan=%d xmod=%d alter=%d\n", this, scan, xmod, alter); @@ -4037,7 +4066,7 @@ int ha_connect::rnd_next(uchar *buf) break; } // endswitch RC - if (trace > 1 && (rc || !(xp->nrd++ % 16384))) { + if (trace(2) && (rc || !(xp->nrd++ % 16384))) { ulonglong tb2= my_interval_timer(); double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL; DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n", @@ -4081,7 +4110,7 @@ void ha_connect::position(const uchar *) DBUG_ENTER("ha_connect::position"); my_store_ptr(ref, ref_length, (my_off_t)tdbp->GetRecpos()); - if (trace > 1) + if (trace(2)) htrc("position: pos=%d\n", tdbp->GetRecpos()); DBUG_VOID_RETURN; @@ -4111,7 +4140,7 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos) DBUG_ENTER("ha_connect::rnd_pos"); if (!tdbp->SetRecpos(xp->g, (int)my_get_ptr(pos, ref_length))) { - if (trace) + if (trace(1)) htrc("rnd_pos: %d\n", tdbp->GetRecpos()); tdbp->SetFilter(NULL); @@ -4177,7 +4206,7 @@ int ha_connect::info(uint flag) DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } // endif g - if (trace) + if (trace(1)) htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info); // tdbp must be available to get updated info @@ -4370,54 +4399,59 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick) my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); return true; } // endif path - } + + } // endif !quick + } else return false; - // check FILE_ACL - // fall through - case TAB_ODBC: - case TAB_JDBC: + // Fall through case TAB_MYSQL: - case TAB_MONGO: case TAB_DIR: - case TAB_MAC: - case TAB_WMI: case TAB_ZIP: case TAB_OEM: #ifdef NO_EMBEDDED_ACCESS_CHECKS - return false; -#endif - /* - If table or table->mdl_ticket is NULL - it's a DLL, e.g. CREATE TABLE. - if the table has an MDL_EXCLUSIVE lock - it's a DDL too, e.g. the - insert step of CREATE ... SELECT. - - Otherwise it's a DML, the table was normally opened, locked, - privilege were already checked, and table->grant.privilege is set. - With SQL SECURITY DEFINER, table->grant.privilege has definer's privileges. - - Unless we're in prelocking mode, in this case table->grant.privilege - is only checked in start_stmt(), not in external_lock(). - */ - if (!table || !table->mdl_ticket || table->mdl_ticket->get_type() == MDL_EXCLUSIVE) - return check_access(thd, FILE_ACL, db, NULL, NULL, 0, 0); - if ((!quick && thd->lex->requires_prelocking()) || table->grant.privilege & FILE_ACL) - return false; - status_var_increment(thd->status_var.access_denied_errors); - my_error(access_denied_error_code(thd->password), MYF(0), - thd->security_ctx->priv_user, thd->security_ctx->priv_host, - (thd->password ? ER(ER_YES) : ER(ER_NO))); - return true; - - // This is temporary until a solution is found + return false; + #endif + + /* + Check FILE_ACL + If table or table->mdl_ticket is NULL - it's a DLL, e.g. CREATE TABLE. + if the table has an MDL_EXCLUSIVE lock - it's a DDL too, e.g. the + insert step of CREATE ... SELECT. + + Otherwise it's a DML, the table was normally opened, locked, + privilege were already checked, and table->grant.privilege is set. + With SQL SECURITY DEFINER, table->grant.privilege has definer's privileges. + + Unless we're in prelocking mode, in this case table->grant.privilege + is only checked in start_stmt(), not in external_lock(). + */ + if (!table || !table->mdl_ticket || table->mdl_ticket->get_type() == MDL_EXCLUSIVE) + return check_access(thd, FILE_ACL, db, NULL, NULL, 0, 0); + + if ((!quick && thd->lex->requires_prelocking()) || table->grant.privilege & FILE_ACL) + return false; + + status_var_increment(thd->status_var.access_denied_errors); + my_error(access_denied_error_code(thd->password), MYF(0), + thd->security_ctx->priv_user, thd->security_ctx->priv_host, + (thd->password ? ER(ER_YES) : ER(ER_NO))); + return true; + case TAB_ODBC: + case TAB_JDBC: + case TAB_MONGO: + case TAB_MAC: + case TAB_WMI: + return false; case TAB_TBL: case TAB_XCL: case TAB_PRX: case TAB_OCCUR: case TAB_PIVOT: case TAB_VIR: - return false; + // This is temporary until a solution is found + return false; } // endswitch type my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0)); @@ -4455,7 +4489,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, #if defined(DEVELOPMENT) if (true) { #else - if (trace) { + if (trace(65)) { #endif LEX_STRING *query_string= thd_query_string(thd); htrc("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd)); @@ -4576,7 +4610,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, } // endif's newmode - if (trace) + if (trace(1)) htrc("New mode=%d\n", newmode); return newmode; @@ -4654,7 +4688,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) DBUG_ASSERT(thd == current_thd); - if (trace) + if (trace(1)) htrc("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n", this, thd, xp, g, lock_type); @@ -4847,7 +4881,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) if (cras) g->Createas= 1; // To tell created table to ignore FLAG - if (trace) { + if (trace(1)) { #if 0 htrc("xcheck=%d cras=%d\n", xcheck, cras); @@ -4880,7 +4914,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) // Delay open until used fields are known } // endif tdbp - if (trace) + if (trace(1)) htrc("external_lock: rc=%d\n", rc); DBUG_RETURN(rc); @@ -5016,7 +5050,7 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) THD *thd= current_thd; int sqlcom= thd_sql_command(thd); - if (trace) { + if (trace(1)) { if (to) htrc("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n", this, thd, sqlcom, name, to); @@ -5127,7 +5161,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, if (index_init(inx, false)) DBUG_RETURN(HA_POS_ERROR); - if (trace) + if (trace(1)) htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing); if (indexing > 0) { @@ -5156,7 +5190,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, else rows= HA_POS_ERROR; - if (trace) + if (trace(1)) htrc("records_in_range: rows=%llu\n", rows); DBUG_RETURN(rows); @@ -5378,7 +5412,7 @@ static int init_table_share(THD* thd, } // endif charset - if (trace) + if (trace(1)) htrc("s_init: %.*s\n", sql->length(), sql->ptr()); return table_s->init_from_sql_statement_string(thd, true, @@ -5411,7 +5445,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, #endif // __WIN__ //int hdr, mxe; int port = 0, mxr = 0, rc = 0, mul = 0, lrecl = 0; - PCSZ tabtyp = NULL; +//PCSZ tabtyp = NULL; #if defined(ODBC_SUPPORT) POPARM sop= NULL; PCSZ ucnc= NULL; @@ -5475,7 +5509,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, #endif // __WIN__ port= atoi(GetListOption(g, "port", topt->oplist, "0")); #if defined(ODBC_SUPPORT) - tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL); +// tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL); mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0")); cto= atoi(GetListOption(g,"ConnectTimeout", topt->oplist, "-1")); qto= atoi(GetListOption(g,"QueryTimeout", topt->oplist, "-1")); @@ -5609,7 +5643,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, #endif // JAVA_SUPPORT case TAB_DBF: dbf = true; - // Passthru + // fall through case TAB_CSV: if (!fn && fnc != FNC_NO) sprintf(g->Message, "Missing %s file name", topt->type); @@ -5788,7 +5822,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd, break; case FNC_TABLE: - qrp = JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp); +// qrp = JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp); + qrp = JDBCTables(g, shm, tab, NULL, mxr, true, sjp); break; #if 0 case FNC_DSN: @@ -5843,12 +5878,12 @@ static int connect_assisted_discovery(handlerton *, THD* thd, case TAB_JSON: qrp = JSONColumns(g, db, dsn, topt, fnc == FNC_COL); break; -#if defined(MONGO_SUPPORT) +#if defined(JAVA_SUPPORT) case TAB_MONGO: url = strz(g, create_info->connect_string); qrp = MGOColumns(g, db, url, topt, fnc == FNC_COL); break; -#endif // MONGO_SUPPORT +#endif // JAVA_SUPPORT #if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT) case TAB_XML: qrp = XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL); @@ -6091,7 +6126,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, } // endif ok } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); rc = HA_ERR_INTERNAL_ERROR; } catch (const char *msg) { @@ -6165,8 +6200,10 @@ int ha_connect::create(const char *name, TABLE *table_arg, TABLE *st= table; // Probably unuseful THD *thd= ha_thd(); LEX_STRING cnc = table_arg->s->connect_string; -#if defined(WITH_PARTITION_STORAGE_ENGINE) +#ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info= table_arg->part_info; +#else +#define part_info 0 #endif // WITH_PARTITION_STORAGE_ENGINE xp= GetUser(thd, xp); PGLOBAL g= xp->g; @@ -6185,7 +6222,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, table= table_arg; // Used by called functions - if (trace) + if (trace(1)) htrc("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n", this, thd, xp, g, sqlcom, GetTableName()); @@ -6268,9 +6305,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, // fall through case TAB_MYSQL: -#if defined(WITH_PARTITION_STORAGE_ENGINE) if (!part_info) -#endif // WITH_PARTITION_STORAGE_ENGINE {const char *src= options->srcdef; PCSZ host, db, tab= options->tabname; int port; @@ -6534,7 +6569,6 @@ int ha_connect::create(const char *name, TABLE *table_arg, } else lwt[i]= tolower(options->type[i]); -#if defined(WITH_PARTITION_STORAGE_ENGINE) if (part_info) { char *p; @@ -6544,7 +6578,6 @@ int ha_connect::create(const char *name, TABLE *table_arg, strcat(strcat(strcpy(buf, p), "."), lwt); *p= 0; } else { -#endif // WITH_PARTITION_STORAGE_ENGINE strcat(strcat(strcpy(buf, GetTableName()), "."), lwt); sprintf(g->Message, "No file name. Table will use %s", buf); @@ -6552,9 +6585,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); -#if defined(WITH_PARTITION_STORAGE_ENGINE) } // endif part_info -#endif // WITH_PARTITION_STORAGE_ENGINE PlugSetPath(fn, buf, dbpath); @@ -6574,7 +6605,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, } // endif sqlcom - if (trace) + if (trace(1)) htrc("xchk=%p createas=%d\n", g->Xchk, g->Createas); if (options->zipped) { @@ -6619,11 +6650,9 @@ int ha_connect::create(const char *name, TABLE *table_arg, push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, "Unexpected command in create, please contact CONNECT team"); -#if defined(WITH_PARTITION_STORAGE_ENGINE) if (part_info && !inward) strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1); // strcpy(partname, part_info->curr_part_elem->partition_name); -#endif // WITH_PARTITION_STORAGE_ENGINE if (g->Alchecked == 0 && (!IsFileType(type) || FileExists(options->filename, false))) { @@ -6659,12 +6688,10 @@ int ha_connect::create(const char *name, TABLE *table_arg, my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); rc = HA_ERR_INTERNAL_ERROR; } else if (cat) { -#if defined(WITH_PARTITION_STORAGE_ENGINE) if (part_info) strncpy(partname, decode(g, strrchr(name, (inward ? slash : '#')) + 1), sizeof(partname) - 1); -#endif // WITH_PARTITION_STORAGE_ENGINE if ((rc= optimize(table->in_use, NULL))) { htrc("Create rc=%d %s\n", rc, g->Message); @@ -6949,7 +6976,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table, xcp->newsep= xcp->SetName(g, GetStringOption("optname")); tshp= NULL; - if (trace && g->Xchk) + if (trace(1) && g->Xchk) htrc( "oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n", xcp->oldsep, xcp->newsep, @@ -7213,10 +7240,11 @@ static struct st_mysql_sys_var* connect_system_variables[]= { MYSQL_SYSVAR(class_path), MYSQL_SYSVAR(java_wrapper), #endif // JAVA_SUPPORT -#if defined(JAVA_SUPPORT) -//MYSQL_SYSVAR(enable_mongo), -#endif // JAVA_SUPPORT -NULL +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) + MYSQL_SYSVAR(enable_mongo), +#endif // JAVA_SUPPORT || CMGO_SUPPORT + MYSQL_SYSVAR(cond_push), + NULL }; maria_declare_plugin(connect) @@ -7229,10 +7257,10 @@ maria_declare_plugin(connect) PLUGIN_LICENSE_GPL, connect_init_func, /* Plugin Init */ connect_done_func, /* Plugin Deinit */ - 0x0106, /* version number (1.05) */ + 0x0107, /* version number (1.05) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.06.0005", /* string version */ + "1.06.0007", /* string version */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/inihandl.cpp b/storage/connect/inihandl.cpp index 96ae0a67a6bdd4d4857106cfd37744fdc797e0ff..c039a980bcba894ae70a20c54cab92be1a014e22 100644 --- a/storage/connect/inihandl.cpp +++ b/storage/connect/inihandl.cpp @@ -293,7 +293,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) next_key = §ion->key; prev_key = NULL; - if (trace > 1) + if (trace(2)) htrc("New section: '%s'\n",section->name); continue; @@ -336,7 +336,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) next_key = &key->next; prev_key = key; - if (trace > 1) + if (trace(2)) htrc("New key: name='%s', value='%s'\n", key->name,key->value?key->value:"(none)"); @@ -359,7 +359,7 @@ static BOOL PROFILE_FlushFile(void) FILE *file = NULL; struct stat buf; - if (trace > 1) + if (trace(2)) htrc("PROFILE_FlushFile: CurProfile=%p\n", CurProfile); if (!CurProfile) { @@ -398,7 +398,7 @@ static BOOL PROFILE_FlushFile(void) return FALSE; } // endif !file - if (trace > 1) + if (trace(2)) htrc("Saving '%s'\n", CurProfile->filename); PROFILE_Save(file, CurProfile->section); @@ -447,7 +447,7 @@ static BOOL PROFILE_Open(LPCSTR filename) struct stat buf; PROFILE *tempProfile; - if (trace > 1) + if (trace(2)) htrc("PROFILE_Open: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES); /* First time around */ @@ -468,7 +468,7 @@ static BOOL PROFILE_Open(LPCSTR filename) /* Check for a match */ for (i = 0; i < N_CACHED_PROFILES; i++) { - if (trace > 1) + if (trace(2)) htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i); if (MRUProfile[i]->filename && !strcmp(filename, MRUProfile[i]->filename)) { @@ -483,11 +483,11 @@ static BOOL PROFILE_Open(LPCSTR filename) } // endif i if (!stat(CurProfile->filename, &buf) && CurProfile->mtime == buf.st_mtime) { - if (trace > 1) + if (trace(2)) htrc("(%s): already opened (mru=%d)\n", filename, i); } else { - if (trace > 1) + if (trace(2)) htrc("(%s): already opened, needs refreshing (mru=%d)\n", filename, i); } // endif stat @@ -535,11 +535,11 @@ static BOOL PROFILE_Open(LPCSTR filename) // strcpy(p, filename); // _strlwr(p); - if (trace > 1) + if (trace(2)) htrc("Opening %s\n", filename); if ((file = fopen(filename, "r"))) { - if (trace > 1) + if (trace(2)) htrc("(%s): found it\n", filename); // CurProfile->unix_name = malloc(strlen(buffer)+1); @@ -574,12 +574,12 @@ void PROFILE_Close(LPCSTR filename) struct stat buf; PROFILE *tempProfile; - if (trace > 1) + if (trace(2)) htrc("PROFILE_Close: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES); /* Check for a match */ for (i = 0; i < N_CACHED_PROFILES; i++) { - if (trace > 1) + if (trace(2)) htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i); if (MRUProfile[i]->filename && !strcmp(filename, MRUProfile[i]->filename)) { @@ -591,7 +591,7 @@ void PROFILE_Close(LPCSTR filename) CurProfile=tempProfile; } // endif i - if (trace > 1) { + if (trace(2)) { if (!stat(CurProfile->filename, &buf) && CurProfile->mtime == buf.st_mtime) htrc("(%s): already opened (mru=%d)\n", filename, i); else @@ -620,7 +620,7 @@ void PROFILE_End(void) { int i; - if (trace) + if (trace(3)) htrc("PROFILE_End: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES); if (!CurProfile) // Sergey Vojtovich @@ -628,7 +628,7 @@ void PROFILE_End(void) /* Close all opened files and free the cache structure */ for (i = 0; i < N_CACHED_PROFILES; i++) { - if (trace) + if (trace(3)) htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i); // CurProfile = MRUProfile[i]; Sergey Vojtovich @@ -894,7 +894,7 @@ static int PROFILE_GetSectionNames(LPSTR buffer, uint len) uint f,l; PROFILESECTION *section; - if (trace > 1) + if (trace(2)) htrc("GetSectionNames: buffer=%p len=%u\n", buffer, len); if (!buffer || !len) @@ -909,17 +909,17 @@ static int PROFILE_GetSectionNames(LPSTR buffer, uint len) buf = buffer; section = CurProfile->section; - if (trace > 1) + if (trace(2)) htrc("GetSectionNames: section=%p\n", section); while (section != NULL) { - if (trace > 1) + if (trace(2)) htrc("section=%s\n", section->name); if (section->name[0]) { l = strlen(section->name) + 1; - if (trace > 1) + if (trace(2)) htrc("l=%u f=%u\n", l, f); if (l > f) { @@ -982,7 +982,7 @@ static int PROFILE_GetString(LPCSTR section, LPCSTR key_name, key = PROFILE_Find(&CurProfile->section, section, key_name, FALSE, FALSE); PROFILE_CopyEntry(buffer, (key && key->value) ? key->value : def_val, len, FALSE); - if (trace > 1) + if (trace(2)) htrc("('%s','%s','%s'): returning '%s'\n", section, key_name, def_val, buffer ); @@ -1010,7 +1010,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, LPCSTR value, BOOL create_always) { if (!key_name) { /* Delete a whole section */ - if (trace > 1) + if (trace(2)) htrc("Deleting('%s')\n", section_name); CurProfile->changed |= PROFILE_DeleteSection(&CurProfile->section, @@ -1018,7 +1018,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, return TRUE; /* Even if PROFILE_DeleteSection() has failed, this is not an error on application's level.*/ } else if (!value) { /* Delete a key */ - if (trace > 1) + if (trace(2)) htrc("Deleting('%s','%s')\n", section_name, key_name); CurProfile->changed |= PROFILE_DeleteKey(&CurProfile->section, @@ -1027,7 +1027,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, } else { /* Set the key value */ PROFILEKEY *key = PROFILE_Find(&CurProfile->section, section_name, key_name, TRUE, create_always); - if (trace > 1) + if (trace(2)) htrc("Setting('%s','%s','%s')\n", section_name, key_name, value); if (!key) @@ -1040,17 +1040,17 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, value++; if (!strcmp(key->value, value)) { - if (trace > 1) + if (trace(2)) htrc(" no change needed\n" ); return TRUE; /* No change needed */ } // endif value - if (trace > 1) + if (trace(2)) htrc(" replacing '%s'\n", key->value); free(key->value); - } else if (trace > 1) + } else if (trace(2)) htrc(" creating key\n" ); key->value = (char*)malloc(strlen(value) + 1); @@ -1345,7 +1345,7 @@ GetPrivateProfileSectionNames(LPSTR buffer, DWORD size, LPCSTR filename) { DWORD ret = 0; - if (trace > 1) + if (trace(2)) htrc("GPPSN: filename=%s\n", filename); EnterCriticalSection(&PROFILE_CritSect); diff --git a/storage/connect/javaconn.cpp b/storage/connect/javaconn.cpp index 90f834ef9a70c4bb0dd95c2b8edd89bc9b412627..d1be0ca1848ca38592f62f9057dd5944019d3c92 100644 --- a/storage/connect/javaconn.cpp +++ b/storage/connect/javaconn.cpp @@ -363,7 +363,7 @@ bool JAVAConn::GetJVM(PGLOBAL g) bool JAVAConn::Open(PGLOBAL g) { bool brc = true, err = false; - jboolean jt = (trace > 0); + jboolean jt = (trace(1)); // Link or check whether jvm library was linked if (GetJVM(g)) @@ -430,7 +430,7 @@ bool JAVAConn::Open(PGLOBAL g) jpop->Append(cp); } // endif cp - if (trace) { + if (trace(1)) { htrc("ClassPath=%s\n", ClassPath); htrc("CLASSPATH=%s\n", cp); htrc("%s\n", jpop->GetStr()); @@ -486,7 +486,7 @@ bool JAVAConn::Open(PGLOBAL g) break; } // endswitch rc - if (trace) + if (trace(1)) htrc("%s\n", g->Message); if (brc) diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index 4c21c2c9681c1535a24be417a88690f7e3db299e..ddbc3115f0b166b4121e98a3e2c3406c86f86c48 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -1,7 +1,7 @@ /************ Jdbconn C++ Functions Source Code File (.CPP) ************/ -/* Name: JDBCONN.CPP Version 1.1 */ +/* Name: JDBCONN.CPP Version 1.2 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2016-2018 */ /* */ /* This file contains the JDBC connection classes functions. */ /***********************************************************************/ @@ -116,10 +116,26 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) return TYPE_ERROR; else len = MY_MIN(abs(len), GetConvSize()); + // Pass through case 12: // VARCHAR + if (tn && !stricmp(tn, "TEXT")) + // Postgresql returns 12 for TEXT + if (GetTypeConv() == TPC_NO) + return TYPE_ERROR; + + // Postgresql can return this + if (len == 0x7FFFFFFF) + len = GetConvSize(); + + // Pass through case -9: // NVARCHAR (unicode) + // Postgresql can return this when size is unknown + if (len == 0x7FFFFFFF) + len = GetConvSize(); + v = 'V'; + // Pass through case 1: // CHAR case -15: // NCHAR (unicode) case -8: // ROWID @@ -154,13 +170,13 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) case 91: // DATE, YEAR type = TYPE_DATE; - if (!tn || toupper(tn[0]) != 'Y') { - len = 10; - v = 'D'; - } else { - len = 4; - v = 'Y'; - } // endif len + if (!tn || toupper(tn[0]) != 'Y') { + len = 10; + v = 'D'; + } else { + len = 4; + v = 'Y'; + } // endif len break; case 92: // TIME @@ -192,6 +208,104 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) return type; } // end of TranslateJDBCType + /***********************************************************************/ + /* A helper class to split an optionally qualified table name into */ + /* components. */ + /* These formats are understood: */ + /* "CatalogName.SchemaName.TableName" */ + /* "SchemaName.TableName" */ + /* "TableName" */ + /***********************************************************************/ +class SQLQualifiedName { + static const uint max_parts = 3; // Catalog.Schema.Table + MYSQL_LEX_STRING m_part[max_parts]; + char m_buf[512]; + + void lex_string_set(MYSQL_LEX_STRING *S, char *str, size_t length) + { + S->str = str; + S->length = length; + } // end of lex_string_set + + void lex_string_shorten_down(MYSQL_LEX_STRING *S, size_t offs) + { + DBUG_ASSERT(offs <= S->length); + S->str += offs; + S->length -= offs; + } // end of lex_string_shorten_down + + /*********************************************************************/ + /* Find the rightmost '.' delimiter and return the length */ + /* of the qualifier, including the rightmost '.' delimier. */ + /* For example, for the string {"a.b.c",5} it will return 4, */ + /* which is the length of the qualifier "a.b." */ + /*********************************************************************/ + size_t lex_string_find_qualifier(MYSQL_LEX_STRING *S) + { + size_t i; + for (i = S->length; i > 0; i--) + { + if (S->str[i - 1] == '.') + { + S->str[i - 1] = '\0'; + return i; + } + } + return 0; + } // end of lex_string_find_qualifier + +public: + /*********************************************************************/ + /* Initialize to the given optionally qualified name. */ + /* NULL pointer in "name" is supported. */ + /* name qualifier has precedence over schema. */ + /*********************************************************************/ + SQLQualifiedName(JCATPARM *cap) + { + const char *name = (const char *)cap->Tab; + char *db = (char *)cap->DB; + size_t len, i; + + // Initialize the parts + for (i = 0; i < max_parts; i++) + lex_string_set(&m_part[i], NULL, 0); + + if (name) { + // Initialize the first (rightmost) part + lex_string_set(&m_part[0], m_buf, + strmake(m_buf, name, sizeof(m_buf) - 1) - m_buf); + + // Initialize the other parts, if exist. + for (i = 1; i < max_parts; i++) { + if (!(len = lex_string_find_qualifier(&m_part[i - 1]))) + break; + + lex_string_set(&m_part[i], m_part[i - 1].str, len - 1); + lex_string_shorten_down(&m_part[i - 1], len); + } // endfor i + + } // endif name + + // If it was not specified, set schema as the passed db name + if (db && !m_part[1].length) + lex_string_set(&m_part[1], db, strlen(db)); + + } // end of SQLQualifiedName + + char *ptr(uint i) + { + DBUG_ASSERT(i < max_parts); + return (char *)(m_part[i].length ? m_part[i].str : NULL); + } // end of ptr + + size_t length(uint i) + { + DBUG_ASSERT(i < max_parts); + return m_part[i].length; + } // end of length + +}; // end of class SQLQualifiedName + /***********************************************************************/ /* Allocate the structure used to refer to the result set. */ /***********************************************************************/ @@ -270,7 +384,7 @@ PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat, length[11] = 255; } // endif jcp - if (trace) + if (trace(1)) htrc("JDBCColumns: max=%d len=%d,%d,%d,%d\n", maxres, length[0], length[1], length[2], length[3]); @@ -287,7 +401,7 @@ PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat, if (info || !qrp) // Info table return qrp; - if (trace) + if (trace(1)) htrc("Getting col results ncol=%d\n", qrp->Nbcol); if (!(cap = AllocCatInfo(g, JCAT_COL, db, table, qrp))) @@ -303,7 +417,7 @@ PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat, qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("Columns: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -394,7 +508,7 @@ PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp, length[4] = 255; } // endif info - if (trace) + if (trace(1)) htrc("JDBCTables: max=%d len=%d,%d\n", maxres, length[0], length[1]); /************************************************************************/ @@ -417,7 +531,7 @@ PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp, cap->Pat = tabtyp; - if (trace) + if (trace(1)) htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol); /************************************************************************/ @@ -427,7 +541,7 @@ PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp, qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("Tables: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -475,7 +589,7 @@ PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info) } else maxres = 0; - if (trace) + if (trace(1)) htrc("JDBCDrivers: max=%d len=%d\n", maxres, length[0]); /************************************************************************/ @@ -519,7 +633,7 @@ JDBConn::JDBConn(PGLOBAL g, PCSZ wrapper) : JAVAConn(g, wrapper) xqid = xuid = xid = grs = readid = fetchid = typid = errid = nullptr; prepid = xpid = pcid = nullptr; chrfldid = intfldid = dblfldid = fltfldid = bigfldid = nullptr; - objfldid = datfldid = timfldid = tspfldid = nullptr; + objfldid = datfldid = timfldid = tspfldid = uidfldid = nullptr; DiscFunc = "JdbcDisconnect"; m_Ncol = 0; m_Aff = 0; @@ -535,12 +649,84 @@ JDBConn::JDBConn(PGLOBAL g, PCSZ wrapper) : JAVAConn(g, wrapper) m_IDQuoteChar[1] = 0; } // end of JDBConn -//JDBConn::~JDBConn() -// { -//if (Connected()) -// EndCom(); +/***********************************************************************/ +/* Search for UUID columns. */ +/***********************************************************************/ +bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp) +{ + int ncol, ctyp; + bool brc = true; + PCSZ fnc = "GetColumns"; + PCOL colp; + JCATPARM *cap; + //jint jtyp; + jboolean rc = false; + jobjectArray parms; + jmethodID catid = nullptr; + + if (gmID(g, catid, fnc, "([Ljava/lang/String;)I")) + return true; + else if (gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I")) + return true; + else if (gmID(g, readid, "ReadNext", "()I")) + return true; + + cap = AllocCatInfo(g, JCAT_COL, tjp->Schema, tjp->TableName, NULL); + SQLQualifiedName name(cap); + + // Build the java string array + parms = env->NewObjectArray(4, env->FindClass("java/lang/String"), NULL); + env->SetObjectArrayElement(parms, 0, env->NewStringUTF(name.ptr(2))); + env->SetObjectArrayElement(parms, 1, env->NewStringUTF(name.ptr(1))); + env->SetObjectArrayElement(parms, 2, env->NewStringUTF(name.ptr(0))); + + for (colp = tjp->GetColumns(); colp; colp = colp->GetNext()) { + env->SetObjectArrayElement(parms, 3, env->NewStringUTF(colp->GetName())); + ncol = env->CallIntMethod(job, catid, parms); + + if (Check(ncol)) { + sprintf(g->Message, "%s: %s", fnc, Msg); + goto err; + } // endif Check + + rc = env->CallBooleanMethod(job, readid); + + if (Check(rc)) { + sprintf(g->Message, "ReadNext: %s", Msg); + goto err; + } else if (rc == 0) { + sprintf(g->Message, "table %s does not exist", tjp->TableName); + goto err; + } // endif rc -// } // end of ~JDBConn + // Returns 666 is case of error + //jtyp = env->CallIntMethod(job, typid, 5, nullptr); + + //if (Check((jtyp == 666) ? -1 : 1)) { + // sprintf(g->Message, "Getting jtyp: %s", Msg); + // goto err; + //} // endif ctyp + + ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr); + + if (Check(ctyp)) { + sprintf(g->Message, "Getting ctyp: %s", Msg); + goto err; + } // endif ctyp + + if (ctyp == 1111) + ((PJDBCCOL)colp)->uuid = true; + + } // endfor colp + + // All is Ok + brc = false; + + err: + // Not used anymore + env->DeleteLocalRef(parms); + return brc; +} // end of SetUUID /***********************************************************************/ /* Utility routine. */ @@ -586,7 +772,7 @@ bool JDBConn::Connect(PJPARM sop) int irc = RC_FX; bool err = false; jint rc; - jboolean jt = (trace > 0); + jboolean jt = (trace(1)); PGLOBAL& g = m_G; /*******************************************************************/ @@ -770,6 +956,7 @@ int JDBConn::Rewind(PCSZ sql) /***********************************************************************/ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) { + const char *field; PGLOBAL& g = m_G; jint ctyp; jstring cn, jn = nullptr; @@ -793,6 +980,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) if (!gmID(g, objfldid, "ObjectField", "(ILjava/lang/String;)Ljava/lang/Object;")) { jb = env->CallObjectMethod(job, objfldid, (jint)rank, jn); + if (Check(0)) { + sprintf(g->Message, "Getting jp: %s", Msg); + throw (int)TYPE_AM_JDBC; + } // endif Check + if (jb == nullptr) { val->Reset(); val->SetNull(true); @@ -818,7 +1010,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) cn = nullptr; if (cn) { - const char *field = env->GetStringUTFChars(cn, (jboolean)false); + field = env->GetStringUTFChars(cn, (jboolean)false); val->SetValue_psz((PSZ)field); } else val->Reset(); @@ -885,6 +1077,19 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) break; case java.sql.Types.BOOLEAN: System.out.print(jdi.BooleanField(i)); */ + case 1111: // UUID + if (!gmID(g, uidfldid, "UuidField", "(ILjava/lang/String;)Ljava/lang/String;")) + cn = (jstring)env->CallObjectMethod(job, uidfldid, (jint)rank, jn); + else + cn = nullptr; + + if (cn) { + const char *field = env->GetStringUTFChars(cn, (jboolean)false); + val->SetValue_psz((PSZ)field); + } else + val->Reset(); + + break; case 0: // NULL val->SetNull(true); // passthru @@ -1055,7 +1260,14 @@ bool JDBConn::SetParam(JDBCCOL *colp) if (gmID(g, setid, "SetNullParm", "(II)I")) return true; - jrc = env->CallIntMethod(job, setid, i, (jint)GetJDBCType(val->GetType())); + jrc = env->CallIntMethod(job, setid, i, + (colp->uuid ? 1111 : (jint)GetJDBCType(val->GetType()))); + } else if (colp->uuid) { + if (gmID(g, setid, "SetUuidParm", "(ILjava/lang/String;)V")) + return true; + + jst = env->NewStringUTF(val->GetCharValue()); + env->CallVoidMethod(job, setid, i, jst); } else switch (val->GetType()) { case TYPE_STRING: if (gmID(g, setid, "SetStringParm", "(ILjava/lang/String;)V")) @@ -1274,105 +1486,6 @@ bool JDBConn::SetParam(JDBCCOL *colp) return qrp; } // end of GetMetaData - /***********************************************************************/ - /* A helper class to split an optionally qualified table name into */ - /* components. */ - /* These formats are understood: */ - /* "CatalogName.SchemaName.TableName" */ - /* "SchemaName.TableName" */ - /* "TableName" */ - /***********************************************************************/ - class SQLQualifiedName - { - static const uint max_parts= 3; // Catalog.Schema.Table - MYSQL_LEX_STRING m_part[max_parts]; - char m_buf[512]; - - void lex_string_set(MYSQL_LEX_STRING *S, char *str, size_t length) - { - S->str= str; - S->length= length; - } // end of lex_string_set - - void lex_string_shorten_down(MYSQL_LEX_STRING *S, size_t offs) - { - DBUG_ASSERT(offs <= S->length); - S->str+= offs; - S->length-= offs; - } // end of lex_string_shorten_down - - /*********************************************************************/ - /* Find the rightmost '.' delimiter and return the length */ - /* of the qualifier, including the rightmost '.' delimier. */ - /* For example, for the string {"a.b.c",5} it will return 4, */ - /* which is the length of the qualifier "a.b." */ - /*********************************************************************/ - size_t lex_string_find_qualifier(MYSQL_LEX_STRING *S) - { - size_t i; - for (i= S->length; i > 0; i--) - { - if (S->str[i - 1] == '.') - { - S->str[i - 1]= '\0'; - return i; - } - } - return 0; - } // end of lex_string_find_qualifier - - public: - /*********************************************************************/ - /* Initialize to the given optionally qualified name. */ - /* NULL pointer in "name" is supported. */ - /* name qualifier has precedence over schema. */ - /*********************************************************************/ - SQLQualifiedName(JCATPARM *cap) - { - const char *name = (const char *)cap->Tab; - char *db = (char *)cap->DB; - size_t len, i; - - // Initialize the parts - for (i = 0; i < max_parts; i++) - lex_string_set(&m_part[i], NULL, 0); - - if (name) { - // Initialize the first (rightmost) part - lex_string_set(&m_part[0], m_buf, - strmake(m_buf, name, sizeof(m_buf) - 1) - m_buf); - - // Initialize the other parts, if exist. - for (i= 1; i < max_parts; i++) { - if (!(len= lex_string_find_qualifier(&m_part[i - 1]))) - break; - - lex_string_set(&m_part[i], m_part[i - 1].str, len - 1); - lex_string_shorten_down(&m_part[i - 1], len); - } // endfor i - - } // endif name - - // If it was not specified, set schema as the passed db name - if (db && !m_part[1].length) - lex_string_set(&m_part[1], db, strlen(db)); - - } // end of SQLQualifiedName - - char *ptr(uint i) - { - DBUG_ASSERT(i < max_parts); - return (char *)(m_part[i].length ? m_part[i].str : NULL); - } // end of ptr - - size_t length(uint i) - { - DBUG_ASSERT(i < max_parts); - return m_part[i].length; - } // end of length - - }; // end of class SQLQualifiedName - /***********************************************************************/ /* Allocate recset and call SQLTables, SQLColumns or SQLPrimaryKeys. */ /***********************************************************************/ @@ -1443,7 +1556,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) // Not used anymore env->DeleteLocalRef(parms); - if (trace) + if (trace(1)) htrc("Method %s returned %d columns\n", fnc, ncol); // n because we no more ignore the first column @@ -1488,7 +1601,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) sprintf(g->Message, "Fetch: %s", Msg); return -1; } if (rc == 0) { - if (trace) + if (trace(1)) htrc("End of fetches i=%d\n", i); break; diff --git a/storage/connect/jdbconn.h b/storage/connect/jdbconn.h index 56f318d238b54e95c92afd850528e0041d9fbad5..0c36cccadcf58fa173d16e6bfea7748f89877cd9 100644 --- a/storage/connect/jdbconn.h +++ b/storage/connect/jdbconn.h @@ -29,6 +29,7 @@ class JDBConn : public JAVAConn { // Attributes public: char *GetQuoteChar(void) { return m_IDQuoteChar; } + bool SetUUID(PGLOBAL g, PTDBJDBC tjp); virtual int GetMaxValue(int infotype); public: @@ -58,13 +59,6 @@ class JDBConn : public JAVAConn { protected: // Members -#if 0 - JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine) - JNIEnv *env; // Pointer to native interface - jclass jdi; // Pointer to the java wrapper class - jobject job; // The java wrapper class object - jmethodID errid; // The GetErrmsg method ID -#endif // 0 jmethodID xqid; // The ExecuteQuery method ID jmethodID xuid; // The ExecuteUpdate method ID jmethodID xid; // The Execute method ID @@ -84,8 +78,7 @@ class JDBConn : public JAVAConn { jmethodID timfldid; // The TimeField method ID jmethodID tspfldid; // The TimestampField method ID jmethodID bigfldid; // The BigintField method ID -// PCSZ Msg; -// PCSZ m_Wrap; + jmethodID uidfldid; // The UuidField method ID char m_IDQuoteChar[2]; PCSZ m_Pwd; int m_Ncol; diff --git a/storage/connect/jmgfam.cpp b/storage/connect/jmgfam.cpp index c7115cdd7202412fd6671412a115bc6ddb3424e5..30f6279146db452c243abb8483f1887da987e30d 100644 --- a/storage/connect/jmgfam.cpp +++ b/storage/connect/jmgfam.cpp @@ -298,7 +298,7 @@ int JMGFAM::ReadBuffer(PGLOBAL g) PSZ str = Jcp->GetDocument(); if (str) { - if (trace == 1) + if (trace(1)) htrc("%s\n", str); strncpy(Tdbp->GetLine(), str, Lrecl); diff --git a/storage/connect/jmgoconn.cpp b/storage/connect/jmgoconn.cpp index 4736641ef3f5c464d16c78d9bf414d4ffeab54c5..1731ccbeb8c2f525867cfeea214b3bdc042337f7 100644 --- a/storage/connect/jmgoconn.cpp +++ b/storage/connect/jmgoconn.cpp @@ -254,7 +254,7 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, all = true; if (pipe && Options) { - if (trace) + if (trace(1)) htrc("Pipeline: %s\n", Options); p = strrchr(Options, ']'); @@ -312,13 +312,13 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, *(char*)p = ']'; // Restore Colist for discovery p = s->GetStr(); - if (trace) + if (trace(33)) htrc("New Pipeline: %s\n", p); return AggregateCollection(p); } else { if (filter || filp) { - if (trace) { + if (trace(1)) { if (filter) htrc("Filter: %s\n", filter); @@ -346,7 +346,7 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, tdbp->SetFilter(NULL); // Not needed anymore } // endif To_Filter - if (trace) + if (trace(33)) htrc("selector: %s\n", s->GetStr()); s->Resize(s->GetLength() + 1); @@ -355,7 +355,7 @@ bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options, if (!all) { if (Options && *Options) { - if (trace) + if (trace(1)) htrc("options=%s\n", Options); op = Options; @@ -751,7 +751,7 @@ int JMgoConn::DocUpdate(PGLOBAL g, PTDB tdbp) jlong ar = env->CallLongMethod(job, updateid, upd); - if (trace) + if (trace(1)) htrc("DocUpdate: ar = %ld\n", ar); if (Check((int)ar)) { @@ -770,7 +770,7 @@ int JMgoConn::DocDelete(PGLOBAL g, bool all) int rc = RC_OK; jlong ar = env->CallLongMethod(job, deleteid, all); - if (trace) + if (trace(1)) htrc("DocDelete: ar = %ld\n", ar); if (Check((int)ar)) { diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index b86d2da21b7cafe23f67c2dc4d0942af87300af1..98a4659cea8ca1c01aa3536692f731d45f32a4fd 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -97,7 +97,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) PJSON jsp = NULL; STRG src; - if (trace) + if (trace(1)) htrc("ParseJson: s=%.10s len=%d\n", s, len); if (!s || !len) { @@ -165,7 +165,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) }; // endswitch s[i] if (!jsp) - sprintf(g->Message, "Invalid Json string '%.*s'", 50, s); + sprintf(g->Message, "Invalid Json string '%.*s'", MY_MIN(len, 50), s); else if (ptyp && pretty == 3) { *ptyp = 3; // Not recognized pretty @@ -178,7 +178,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) } // endif ptyp } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); jsp = NULL; } catch (const char *msg) { @@ -652,7 +652,7 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty) } // endif's } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); str = NULL; } catch (const char *msg) { @@ -1015,6 +1015,20 @@ PJAR JOBJECT::GetKeyList(PGLOBAL g) return jarp; } // end of GetKeyList +/***********************************************************************/ +/* Return all values as an array. */ +/***********************************************************************/ +PJAR JOBJECT::GetValList(PGLOBAL g) +{ + PJAR jarp = new(g) JARRAY(); + + for (PJPR jpp = First; jpp; jpp = jpp->Next) + jarp->AddValue(g, jpp->GetVal()); + + jarp->InitArray(g); + return jarp; +} // end of GetValList + /***********************************************************************/ /* Get the value corresponding to the given key. */ /***********************************************************************/ @@ -1224,6 +1238,7 @@ PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x) Last->Next = jvp; Last = jvp; + Last->Next = NULL; } // endif x return jvp; @@ -1318,6 +1333,24 @@ bool JARRAY::IsNull(void) /* -------------------------- Class JVALUE- -------------------------- */ +/***********************************************************************/ +/* Constructor for a JSON. */ +/***********************************************************************/ +JVALUE::JVALUE(PJSON jsp) : JSON() +{ + if (jsp->GetType() == TYPE_JVAL) { + Jsp = jsp->GetJsp(); + Value = jsp->GetValue(); + } else { + Jsp = jsp; + Value = NULL; + } // endif Type + + Next = NULL; + Del = false; + Size = 1; +} // end of JVALUE constructor + /***********************************************************************/ /* Constructor for a Value with a given string or numeric value. */ /***********************************************************************/ diff --git a/storage/connect/json.h b/storage/connect/json.h index 375532212c48e30305a107604ac8cb92653244b3..dcc97287420f6b898dfe1989ad9573b330895059 100644 --- a/storage/connect/json.h +++ b/storage/connect/json.h @@ -20,7 +20,8 @@ enum JTYP {TYPE_NULL = TYPE_VOID, TYPE_BINT = TYPE_BIGINT, TYPE_DTM = TYPE_DATE, TYPE_INTG = TYPE_INT, - TYPE_JSON = 12, + TYPE_VAL = 12, + TYPE_JSON, TYPE_JAR, TYPE_JOB, TYPE_JVAL}; @@ -157,6 +158,7 @@ class JSON : public BLOCK { //virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;} virtual PJPR AddPair(PGLOBAL g, PCSZ key) {X return NULL;} virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;} + virtual PJAR GetValList(PGLOBAL g) {X return NULL;} virtual PJVAL GetValue(const char *key) {X return NULL;} virtual PJOB GetObject(void) {return NULL;} virtual PJAR GetArray(void) {return NULL;} @@ -205,6 +207,7 @@ class JOBJECT : public JSON { virtual PJOB GetObject(void) {return this;} virtual PJVAL GetValue(const char* key); virtual PJAR GetKeyList(PGLOBAL g); + virtual PJAR GetValList(PGLOBAL g); virtual PSZ GetText(PGLOBAL g, PSZ text); virtual bool Merge(PGLOBAL g, PJSON jsp); virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key); @@ -258,8 +261,7 @@ class JVALUE : public JSON { friend bool SerializeValue(JOUT *, PJVAL); public: JVALUE(void) : JSON() {Clear();} - JVALUE(PJSON jsp) : JSON() - {Jsp = jsp; Value = NULL; Next = NULL; Del = false; Size = 1;} + JVALUE(PJSON jsp); JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PCSZ strp); diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 33af95a2bbc421e7de758310bc06eec17a333952..794a84f22c492fd8b3a874ba25581479daf72c01 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1,6 +1,6 @@ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/ -/* PROGRAM NAME: jsonudf Version 1.6 */ -/* (C) Copyright to the author Olivier BERTRAND 2015-2017 */ +/* PROGRAM NAME: jsonudf Version 1.7 */ +/* (C) Copyright to the author Olivier BERTRAND 2015-2018 */ /* This program are the JSON User Defined Functions . */ /*********************************************************************************/ @@ -31,16 +31,39 @@ bool IsNum(PSZ s); char *NextChr(PSZ s, char sep); char *GetJsonNull(void); uint GetJsonGrpSize(void); -static int IsJson(UDF_ARGS *args, uint i); +static int IsJson(UDF_ARGS *args, uint i, bool b = false); static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); static char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error); static char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error); +static PJSON JsonNew(PGLOBAL g, JTYP type); +static PJVAL JvalNew(PGLOBAL g, JTYP type, void *vp = NULL); +static PJSNX JsnxNew(PGLOBAL g, PJSON jsp, int type, int len = 64); static uint JsonGrpSize = 10; -/* ----------------------------------- JSNX ------------------------------------ */ +/*********************************************************************************/ +/* SubAlloc a new JSNX class with protection against memory exhaustion. */ +/*********************************************************************************/ +static PJSNX JsnxNew(PGLOBAL g, PJSON jsp, int type, int len) +{ + PJSNX jsx; + + try { + jsx = new(g) JSNX(g, jsp, type, len); + } catch (...) { + if (trace(1023)) + htrc("%s\n", g->Message); + + PUSH_WARNING(g->Message); + jsx = NULL; + } // end try/catch + + return jsx; +} /* end of JsnxNew */ + + /* ----------------------------------- JSNX ------------------------------------ */ /*********************************************************************************/ /* JSNX public constructor. */ @@ -81,21 +104,7 @@ my_bool JSNX::SetJpath(PGLOBAL g, char *path, my_bool jb) return true; Value->SetNullable(true); - -#if 0 - if (jb) { - // Path must return a Json item - size_t n = strlen(path); - - if (!n || path[n - 1] != '*') { - Jpath = (char*)PlugSubAlloc(g, NULL, n + 3); - strcat(strcpy(Jpath, path), (n) ? ":*" : "*"); - } else - Jpath = path; - - } else -#endif // 0 - Jpath = path; + Jpath = path; // Parse the json path Parsed = false; @@ -182,7 +191,7 @@ my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) // Set concat intermediate string p[n - 1] = 0; - if (trace) + if (trace(1)) htrc("Concat string=%s\n", p + 1); jnp->CncVal = AllocateValue(g, p + 1, TYPE_STRING); @@ -246,7 +255,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g) // Jpath = Name; return true; - if (trace) + if (trace(1)) htrc("ParseJpath %s\n", SVP(Jpath)); if (!(pbuf = PlgDBDup(g, Jpath))) @@ -309,7 +318,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g) Nod = i; MulVal = AllocateValue(g, Value); - if (trace) + if (trace(1)) for (i = 0; i < Nod; i++) htrc("Node(%d) Key=%s Op=%d Rank=%d\n", i, SVP(Nodes[i].Key), Nodes[i].Op, Nodes[i].Rank); @@ -506,13 +515,13 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) vp->Reset(); - if (trace) + if (trace(1)) htrc("CalculateArray size=%d op=%d\n", ars, op); - for (i = 0; i < arp->size(); i++) { + for (i = 0; i < ars; i++) { jvrp = arp->GetValue(i); - if (trace) + if (trace(1)) htrc("i=%d nv=%d\n", i, nv); if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) { @@ -525,7 +534,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) } else jvp = jvrp; - if (trace) + if (trace(1)) htrc("jvp=%s null=%d\n", jvp->GetString(g), jvp->IsNull() ? 1 : 0); @@ -561,7 +570,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) if (err) vp->Reset(); - if (trace) { + if (trace(1)) { char buf(32); htrc("vp='%s' err=%d\n", @@ -753,6 +762,7 @@ my_bool JSNX::WriteValue(PGLOBAL g, PJVAL jvalp) /*********************************************************************************/ PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k) { + PSZ str = NULL; my_bool b = false, err = true; g->Message[0] = 0; @@ -762,37 +772,47 @@ PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k) return NULL; } // endif jsp - // Write to the path string - Jp = new(g) JOUTSTR(g); - Jp->WriteChr('$'); - Jvalp = jvp; - K = k; + try { + // Write to the path string + Jp = new(g) JOUTSTR(g); + Jp->WriteChr('$'); + Jvalp = jvp; + K = k; - switch (jsp->GetType()) { - case TYPE_JAR: - err = LocateArray((PJAR)jsp); - break; - case TYPE_JOB: - err = LocateObject((PJOB)jsp); - break; - case TYPE_JVAL: - err = LocateValue((PJVAL)jsp); - break; - default: - err = true; + switch (jsp->GetType()) { + case TYPE_JAR: + err = LocateArray((PJAR)jsp); + break; + case TYPE_JOB: + err = LocateObject((PJOB)jsp); + break; + case TYPE_JVAL: + err = LocateValue((PJVAL)jsp); + break; + default: + err = true; } // endswitch Type - if (err) { - if (!g->Message[0]) - strcpy(g->Message, "Invalid json tree"); + if (err) { + if (!g->Message[0]) + strcpy(g->Message, "Invalid json tree"); - } else if (Found) { - Jp->WriteChr('\0'); - PlugSubAlloc(g, NULL, Jp->N); - return Jp->Strp; - } // endif's + } else if (Found) { + Jp->WriteChr('\0'); + PlugSubAlloc(g, NULL, Jp->N); + str = Jp->Strp; + } // endif's - return NULL; + } catch (int n) { + if (trace(1)) + htrc("Exception %d: %s\n", n, g->Message); + + PUSH_WARNING(g->Message); + } catch (const char *msg) { + strcpy(g->Message, msg); + } // end catch + + return str; } // end of Locate /*********************************************************************************/ @@ -864,53 +884,62 @@ my_bool JSNX::LocateValue(PJVAL jvp) /*********************************************************************************/ PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx) { + PSZ str = NULL; my_bool b = false, err = true; - PJPN jnp = (PJPN)PlugSubAlloc(g, NULL, sizeof(JPN) * mx); - - memset(jnp, 0, sizeof(JPN) * mx); - g->Message[0] = 0; - + PJPN jnp; + if (!jsp) { strcpy(g->Message, "Null json tree"); return NULL; } // endif jsp - // Write to the path string - Jp = new(g)JOUTSTR(g); - Jvalp = jvp; - Imax = mx - 1; - Jpnp = jnp; - Jp->WriteChr('['); + try { + jnp = (PJPN)PlugSubAlloc(g, NULL, sizeof(JPN) * mx); + memset(jnp, 0, sizeof(JPN) * mx); + g->Message[0] = 0; + + // Write to the path string + Jp = new(g)JOUTSTR(g); + Jvalp = jvp; + Imax = mx - 1; + Jpnp = jnp; + Jp->WriteChr('['); + + switch (jsp->GetType()) { + case TYPE_JAR: + err = LocateArrayAll((PJAR)jsp); + break; + case TYPE_JOB: + err = LocateObjectAll((PJOB)jsp); + break; + case TYPE_JVAL: + err = LocateValueAll((PJVAL)jsp); + break; + default: + err = true; + } // endswitch Type - switch (jsp->GetType()) { - case TYPE_JAR: - err = LocateArrayAll((PJAR)jsp); - break; - case TYPE_JOB: - err = LocateObjectAll((PJOB)jsp); - break; - case TYPE_JVAL: - err = LocateValueAll((PJVAL)jsp); - break; - default: - err = true; - } // endswitch Type + if (!err) { + if (Jp->N > 1) + Jp->N--; - if (err) { - if (!g->Message[0]) + Jp->WriteChr(']'); + Jp->WriteChr('\0'); + PlugSubAlloc(g, NULL, Jp->N); + str = Jp->Strp; + } else if (!g->Message[0]) strcpy(g->Message, "Invalid json tree"); - return NULL; - } else { - if (Jp->N > 1) - Jp->N--; + } catch (int n) { + if (trace(1)) + htrc("Exception %d: %s\n", n, g->Message); - Jp->WriteChr(']'); - Jp->WriteChr('\0'); - PlugSubAlloc(g, NULL, Jp->N); - return Jp->Strp; - } // endif's + PUSH_WARNING(g->Message); + } catch (const char *msg) { + strcpy(g->Message, msg); + } // end catch + return str; } // end of LocateAll /*********************************************************************************/ @@ -1137,6 +1166,72 @@ inline void JsonFreeMem(PGLOBAL g) PlugExit(g); } /* end of JsonFreeMem */ +/*********************************************************************************/ +/* SubAlloc a new JSON item with protection against memory exhaustion. */ +/*********************************************************************************/ +static PJSON JsonNew(PGLOBAL g, JTYP type) +{ + PJSON jsp = NULL; + + try { + switch (type) { + case TYPE_JAR: + jsp = new(g) JARRAY; + break; + case TYPE_JOB: + jsp = new(g) JOBJECT; + break; + default: + break; + } // endswitch type + + } catch (...) { + if (trace(1023)) + htrc("%s\n", g->Message); + + PUSH_WARNING(g->Message); + } // end try/catch + + return jsp; +} /* end of JsonNew */ + +/*********************************************************************************/ +/* SubAlloc a new JValue with protection against memory exhaustion. */ +/*********************************************************************************/ +static PJVAL JvalNew(PGLOBAL g, JTYP type, void *vp) +{ + PJVAL jvp = NULL; + + try { + if (!vp) + jvp = new (g) JVALUE; + else switch (type) { + case TYPE_JSON: + case TYPE_JVAL: + case TYPE_JAR: + case TYPE_JOB: + jvp = new(g) JVALUE((PJSON)vp); + break; + case TYPE_VAL: + jvp = new(g) JVALUE(g, (PVAL)vp); + break; + case TYPE_STRG: + jvp = new(g) JVALUE(g, (PCSZ)vp); + break; + default: + break; + } // endswitch type + + } catch (...) { + if (trace(1023)) + htrc("%s\n", g->Message); + + PUSH_WARNING(g->Message); + } // end try/catch + + return jvp; +} /* end of JsonNew */ + /*********************************************************************************/ /* Allocate and initialise the memory area. */ /*********************************************************************************/ @@ -1289,8 +1384,11 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n) for (uint i = n; i < args->arg_count; i++) if (args->arg_type[i] == INT_RESULT) { if (args->args[i]) { - x = (int*)PlugSubAlloc(g, NULL, sizeof(int)); - *x = (int)*(longlong*)args->args[i]; + if ((x = (int*)PlgDBSubAlloc(g, NULL, sizeof(int)))) + *x = (int)*(longlong*)args->args[i]; + else + PUSH_WARNING(g->Message); + } // endif args n = i + 1; @@ -1303,7 +1401,7 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n) /*********************************************************************************/ /* Returns not 0 if the argument is a JSON item or file name. */ /*********************************************************************************/ -static int IsJson(UDF_ARGS *args, uint i) +static int IsJson(UDF_ARGS *args, uint i, bool b) { int n = 0; @@ -1320,8 +1418,20 @@ static int IsJson(UDF_ARGS *args, uint i) else n = 2; // A file name may have been returned - } else if (!strnicmp(args->attributes[i], "Jfile_", 6)) + } else if (!strnicmp(args->attributes[i], "Jfile_", 6)) { n = 2; // arg is a json file name + } else if (b) { + char *sap; + PGLOBAL g = PlugInit(NULL, args->lengths[i] * M + 1024); + + JsonSubSet(g); + sap = MakePSZ(g, args, i); + + if (ParseJson(g, sap, strlen(sap))) + n = 4; + + JsonFreeMem(g); + } // endif's return n; } // end of IsJson @@ -1534,10 +1644,14 @@ static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i) { if (args->arg_count > (unsigned)i && args->args[i]) { int n = args->lengths[i]; - PSZ s = (PSZ)PlugSubAlloc(g, NULL, n + 1); + PSZ s = (PSZ)PlgDBSubAlloc(g, NULL, n + 1); + + if (s) { + memcpy(s, args->args[i], n); + s[n] = 0; + } else + PUSH_WARNING(g->Message); - memcpy(s, args->args[i], n); - s[n] = 0; return s; } else return NULL; @@ -1574,9 +1688,12 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) return "Key"; if (!b) { - p = (PSZ)PlugSubAlloc(g, NULL, n + 1); - memcpy(p, s, n); - p[n] = 0; + if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { + memcpy(p, s, n); + p[n] = 0; + } else + PUSH_WARNING(g->Message); + s = p; } // endif b @@ -1665,15 +1782,16 @@ static char *GetJsonFile(PGLOBAL g, char *fn) return NULL; } // endif len - str = (char*)PlugSubAlloc(g, NULL, len + 1); - - if ((n = read(h, str, len)) < 0) { - sprintf(g->Message, "Error %d reading %d bytes from %s", errno, len, fn); - return NULL; - } // endif n + if ((str = (char*)PlgDBSubAlloc(g, NULL, len + 1))) { + if ((n = read(h, str, len)) < 0) { + sprintf(g->Message, "Error %d reading %d bytes from %s", errno, len, fn); + return NULL; + } // endif n - str[n] = 0; - close(h); + str[n] = 0; + close(h); + } // endif str + return str; } // end of GetJsonFile @@ -1759,6 +1877,41 @@ static PJVAL MakeValue(PGLOBAL g, UDF_ARGS *args, uint i, PJSON *top = NULL) return jvp; } // end of MakeValue +/*********************************************************************************/ +/* Try making a JSON value of the passed type from the passed argument. */ +/*********************************************************************************/ +static PJVAL MakeTypedValue(PGLOBAL g, UDF_ARGS *args, uint i, + JTYP type, PJSON *top = NULL) +{ + char *sap; + PJSON jsp; + PJVAL jvp = MakeValue(g, args, i, top); + + //if (type == TYPE_JSON) { + // if (jvp->GetValType() >= TYPE_JSON) + // return jvp; + + //} else if (jvp->GetValType() == type) + // return jvp; + + if (jvp->GetValType() == TYPE_STRG) { + sap = jvp->GetString(g); + + if ((jsp = ParseJson(g, sap, strlen(sap)))) { + if ((type == TYPE_JSON && jsp->GetType() != TYPE_JVAL) || jsp->GetType() == type) { + if (top) + *top = jsp; + + jvp->SetValue(jsp); + } // endif Type + + } // endif jsp + + } // endif Type + + return jvp; +} // end of MakeTypedValue + /*********************************************************************************/ /* Make a Json value containing the parameter. */ /*********************************************************************************/ @@ -1861,9 +2014,9 @@ my_bool json_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *messa if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); return true; - } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { - strcpy(message, "First argument must be a json string or item"); - return true; + //} else if (!IsJson(args, 0, true)) { + // strcpy(message, "First argument must be a valid json string or item"); + // return true; } else CalcLen(args, false, reslen, memlen); @@ -1891,23 +2044,14 @@ char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!g->Xchk) { if (!CheckMemory(g, initid, args, args->arg_count, true)) { - char *p; PJSON top; PJAR arp; - PJVAL jvp = MakeValue(g, args, 0, &top); + PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JAR, &top); - if ((p = jvp->GetString(g))) { - if (!(top = ParseJson(g, p, strlen(p)))) { - PUSH_WARNING(g->Message); - return NULL; - } // endif jsp - - jvp->SetValue(top); - } // endif p - if (jvp->GetValType() != TYPE_JAR) { arp = new(g)JARRAY; arp->AddValue(g, jvp); + top = arp; } else arp = jvp->GetArray(); @@ -1915,7 +2059,6 @@ char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, arp->AddValue(g, MakeValue(g, args, i)); arp->InitArray(g); -// str = Serialize(g, arp, NULL, 0); str = MakeResult(g, args, top, args->arg_count); } // endif CheckMemory @@ -1952,10 +2095,10 @@ my_bool json_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); - return true; - } else if (!IsJson(args, 0)) { - strcpy(message, "First argument must be a json item"); - return true; + return true; + //} else if (!IsJson(args, 0, true)) { + // strcpy(message, "First argument is not a valid Json item"); + // return true; } else CalcLen(args, false, reslen, memlen, true); @@ -1994,22 +2137,38 @@ char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result, PJVAL jvp; PJAR arp; - jvp = MakeValue(g, args, 0, &top); + jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top); jsp = jvp->GetJson(); x = GetIntArgPtr(g, args, n); if (CheckPath(g, args, jsp, jvp, 2)) PUSH_WARNING(g->Message); - else if (jvp && jvp->GetValType() == TYPE_JAR) { + else if (jvp) { PGLOBAL gb = GetMemPtr(g, args, 0); - arp = jvp->GetArray(); - arp->AddValue(gb, MakeValue(gb, args, 1), x); - arp->InitArray(gb); - str = MakeResult(g, args, top, n); + if (jvp->GetValType() != TYPE_JAR) { + if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) { + arp->AddValue(gb, JvalNew(gb, TYPE_JVAL, jvp)); + jvp->SetValue(arp); + + if (!top) + top = arp; + + } // endif arp + + } else + arp = jvp->GetArray(); + + if (arp) { + arp->AddValue(gb, MakeValue(gb, args, 1), x); + arp->InitArray(gb); + str = MakeResult(g, args, top, n); + } else + PUSH_WARNING(gb->Message); + } else { - PUSH_WARNING("First argument target is not an array"); -// if (g->Mrr) *error = 1; (only if no path) + PUSH_WARNING("Target is not an array"); + // if (g->Mrr) *error = 1; (only if no path) } // endif jvp } // endif CheckMemory @@ -2048,9 +2207,6 @@ my_bool json_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); return true; - } else if (!IsJson(args, 0)) { - strcpy(message, "First argument must be a json item"); - return true; } else CalcLen(args, false, reslen, memlen, true); @@ -2087,7 +2243,7 @@ char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, uint n = 1; PJSON top; PJAR arp; - PJVAL jvp = MakeValue(g, args, 0, &top); + PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top); if (!(x = GetIntArgPtr(g, args, n))) PUSH_WARNING("Missing or null array index"); @@ -2186,9 +2342,14 @@ long long jsonsum_int(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *err if (g->N) { // Keep result of constant function - long long *np = (long long*)PlugSubAlloc(g, NULL, sizeof(long long)); - *np = n; - g->Activityp = (PACTIVITY)np; + long long *np; + + if ((np = (long long*)PlgDBSubAlloc(g, NULL, sizeof(long long)))) { + *np = n; + g->Activityp = (PACTIVITY)np; + } else + PUSH_WARNING(g->Message); + } // endif const_item return n; @@ -2252,13 +2413,21 @@ double jsonsum_real(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error } else { *error = 1; n = -1.0; - } // end of CheckMemory + } // endif CheckMemory if (g->N) { // Keep result of constant function - double *np = (double*)PlugSubAlloc(g, NULL, sizeof(double)); - *np = n; - g->Activityp = (PACTIVITY)np; + double *np; + + if ((np = (double*)PlgDBSubAlloc(g, NULL, sizeof(double)))) { + *np = n; + g->Activityp = (PACTIVITY)np; + } else { + PUSH_WARNING(g->Message); + *error = 1; + n = -1.0; + } // endif np + } // endif const_item return n; @@ -2312,13 +2481,20 @@ double jsonavg_real(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error } else { *error = 1; n = -1.0; - } // end of CheckMemory + } // endif CheckMemory if (g->N) { // Keep result of constant function - double *np = (double*)PlugSubAlloc(g, NULL, sizeof(double)); - *np = n; - g->Activityp = (PACTIVITY)np; + double *np; + + if ((np = (double*)PlgDBSubAlloc(g, NULL, sizeof(double)))) { + *np = n; + g->Activityp = (PACTIVITY)np; + } else { + *error = 1; + n = -1.0; + } // endif np + } // endif const_item return n; @@ -2348,12 +2524,15 @@ char *json_make_object(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!g->Xchk) { if (!CheckMemory(g, initid, args, args->arg_count, false, false, true)) { - PJOB objp = new(g)JOBJECT; + PJOB objp; + + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i++) + objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i)); - for (uint i = 0; i < args->arg_count; i++) - objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i)); + str = Serialize(g, objp, NULL, 0); + } // endif objp - str = Serialize(g, objp, NULL, 0); } // endif CheckMemory if (!str) @@ -2394,13 +2573,16 @@ char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!g->Xchk) { if (!CheckMemory(g, initid, args, args->arg_count, false, true)) { PJVAL jvp; - PJOB objp = new(g)JOBJECT; + PJOB objp; + + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i++) + if (!(jvp = MakeValue(g, args, i))->IsNull()) + objp->SetValue(g, jvp, MakeKey(g, args, i)); - for (uint i = 0; i < args->arg_count; i++) - if (!(jvp = MakeValue(g, args, i))->IsNull()) - objp->SetValue(g, jvp, MakeKey(g, args, i)); + str = Serialize(g, objp, NULL, 0); + } // endif objp - str = Serialize(g, objp, NULL, 0); } // endif CheckMemory if (!str) @@ -2444,12 +2626,15 @@ char *json_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!g->Xchk) { if (!CheckMemory(g, initid, args, args->arg_count, false, true)) { - PJOB objp = new(g)JOBJECT; + PJOB objp; + + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i += 2) + objp->SetValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i)); - for (uint i = 0; i < args->arg_count; i += 2) - objp->SetValue(g, MakeValue(g, args, i+1), MakePSZ(g, args, i)); + str = Serialize(g, objp, NULL, 0); + } // endif objp - str = Serialize(g, objp, NULL, 0); } // endif CheckMemory if (!str) @@ -2731,6 +2916,82 @@ void json_object_list_deinit(UDF_INIT* initid) JsonFreeMem((PGLOBAL)initid->ptr); } // end of json_object_list_deinit +/*********************************************************************************/ +/* Returns an array of the Json object values. */ +/*********************************************************************************/ +my_bool json_object_values_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + unsigned long reslen, memlen; + + if (args->arg_count != 1) { + strcpy(message, "This function must have 1 argument"); + return true; + } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { + strcpy(message, "Argument must be a json object"); + return true; + } else + CalcLen(args, false, reslen, memlen); + + return JsonInit(initid, args, message, true, reslen, memlen); +} // end of json_object_list_init + +char *json_object_values(UDF_INIT *initid, UDF_ARGS *args, char *result, + unsigned long *res_length, char *is_null, char *error) +{ + char *str = NULL; + PGLOBAL g = (PGLOBAL)initid->ptr; + + if (!g->N) { + if (!CheckMemory(g, initid, args, 1, true, true)) { + char *p; + PJSON jsp; + PJVAL jvp = MakeValue(g, args, 0); + + if ((p = jvp->GetString(g))) { + if (!(jsp = ParseJson(g, p, strlen(p)))) { + PUSH_WARNING(g->Message); + return NULL; + } // endif jsp + + } else + jsp = jvp->GetJson(); + + if (jsp->GetType() == TYPE_JOB) { + PJAR jarp = ((PJOB)jsp)->GetValList(g); + + if (!(str = Serialize(g, jarp, NULL, 0))) + PUSH_WARNING(g->Message); + + } else { + PUSH_WARNING("First argument is not an object"); + if (g->Mrr) *error = 1; + } // endif jvp + + } // endif CheckMemory + + if (initid->const_item) { + // Keep result of constant function + g->Xchk = str; + g->N = 1; // str can be NULL + } // endif const_item + + } else + str = (char*)g->Xchk; + + if (!str) { + *is_null = 1; + *res_length = 0; + } else + *res_length = strlen(str); + + return str; +} // end of json_object_values + +void json_object_values_deinit(UDF_INIT* initid) +{ + JsonFreeMem((PGLOBAL)initid->ptr); +} // end of json_object_values_deinit + /*********************************************************************************/ /* Set the value of JsonGrpSize. */ /*********************************************************************************/ @@ -2795,7 +3056,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; PlugSubSet(g, g->Sarea, g->Sarea_Size); - g->Activityp = (PACTIVITY)new(g) JARRAY; + g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); g->N = (int)n; return false; } // end of json_array_grp_init @@ -2805,7 +3066,7 @@ void json_array_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) PGLOBAL g = (PGLOBAL)initid->ptr; PJAR arp = (PJAR)g->Activityp; - if (g->N-- > 0) + if (arp && g->N-- > 0) arp->AddValue(g, MakeValue(g, args, 0)); } // end of json_array_grp_add @@ -2820,12 +3081,16 @@ char *json_array_grp(UDF_INIT *initid, UDF_ARGS *, char *result, if (g->N < 0) PUSH_WARNING("Result truncated to json_grp_size values"); - arp->InitArray(g); + if (arp) { + arp->InitArray(g); + str = Serialize(g, arp, NULL, 0); + } else + str = NULL; - if (!(str = Serialize(g, arp, NULL, 0))) - str = strcpy(result, g->Message); + if (!str) + str = strcpy(result, g->Message); - *res_length = strlen(str); + *res_length = strlen(str); return str; } // end of json_array_grp @@ -2834,8 +3099,8 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*) PGLOBAL g = (PGLOBAL)initid->ptr; PlugSubSet(g, g->Sarea, g->Sarea_Size); - g->Activityp = (PACTIVITY)new(g) JARRAY; - g->N = GetJsonGroupSize(); + g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); + g->N = GetJsonGroupSize(); } // end of json_array_grp_clear void json_array_grp_deinit(UDF_INIT* initid) @@ -2868,7 +3133,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; PlugSubSet(g, g->Sarea, g->Sarea_Size); - g->Activityp = (PACTIVITY)new(g) JOBJECT; + g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); g->N = (int)n; return false; } // end of json_object_grp_init @@ -2893,7 +3158,7 @@ char *json_object_grp(UDF_INIT *initid, UDF_ARGS *, char *result, if (g->N < 0) PUSH_WARNING("Result truncated to json_grp_size values"); - if (!(str = Serialize(g, objp, NULL, 0))) + if (!objp || !(str = Serialize(g, objp, NULL, 0))) str = strcpy(result, g->Message); *res_length = strlen(str); @@ -2905,8 +3170,8 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*) PGLOBAL g = (PGLOBAL)initid->ptr; PlugSubSet(g, g->Sarea, g->Sarea_Size); - g->Activityp = (PACTIVITY)new(g) JOBJECT; - g->N = GetJsonGroupSize(); + g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); + g->N = GetJsonGroupSize(); } // end of json_object_grp_clear void json_object_grp_deinit(UDF_INIT* initid) @@ -3051,7 +3316,7 @@ my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *) { - char *p, *path, *str = NULL; + char *path, *str = NULL; PJSON jsp; PJVAL jvp; PJSNX jsx; @@ -3067,17 +3332,10 @@ char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, if (CheckMemory(g, initid, args, 1, true, true)) { PUSH_WARNING("CheckMemory error"); goto fin; - } else - jvp = MakeValue(g, args, 0); - - if ((p = jvp->GetString(g))) { - if (!(jsp = ParseJson(g, p, strlen(p)))) { - PUSH_WARNING(g->Message); - return NULL; - } // endif jsp + } // endif CheckMemory - } else - jsp = jvp->GetJson(); + jvp = MakeTypedValue(g, args, 0, TYPE_JSON); + jsp = jvp->GetJson(); if (g->Mrr) { // First argument is a constant g->Xchk = jsp; @@ -3088,9 +3346,9 @@ char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length); + jsx = JsnxNew(g, jsp, TYPE_STRING, initid->max_length); - if (jsx->SetJpath(g, path, true)) { + if (!jsx || jsx->SetJpath(g, path, true)) { PUSH_WARNING(g->Message); *is_null = 1; return NULL; @@ -3203,9 +3461,9 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length); + jsx = JsnxNew(g, jsp, TYPE_STRING, initid->max_length); - if (jsx->SetJpath(g, path)) { + if (!jsx || jsx->SetJpath(g, path)) { PUSH_WARNING(g->Message); goto err; } // endif SetJpath @@ -3220,7 +3478,7 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result, g->Activityp = (PACTIVITY)str; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); PUSH_WARNING(g->Message); @@ -3320,9 +3578,9 @@ long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g) JSNX(g, jsp, TYPE_BIGINT); + jsx = JsnxNew(g, jsp, TYPE_BIGINT); - if (jsx->SetJpath(g, path)) { + if (!jsx || jsx->SetJpath(g, path)) { PUSH_WARNING(g->Message); *is_null = 1; return 0; @@ -3339,9 +3597,14 @@ long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args, if (initid->const_item) { // Keep result of constant function - long long *np = (long long*)PlugSubAlloc(g, NULL, sizeof(long long)); - *np = n; - g->Activityp = (PACTIVITY)np; + long long *np = (long long*)PlgDBSubAlloc(g, NULL, sizeof(long long)); + + if (np) { + *np = n; + g->Activityp = (PACTIVITY)np; + } else + PUSH_WARNING(g->Message); + } // endif const_item return n; @@ -3434,9 +3697,9 @@ double jsonget_real(UDF_INIT *initid, UDF_ARGS *args, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g) JSNX(g, jsp, TYPE_DOUBLE); + jsx = JsnxNew(g, jsp, TYPE_DOUBLE); - if (jsx->SetJpath(g, path)) { + if (!jsx || jsx->SetJpath(g, path)) { PUSH_WARNING(g->Message); *is_null = 1; return 0.0; @@ -3453,9 +3716,17 @@ double jsonget_real(UDF_INIT *initid, UDF_ARGS *args, if (initid->const_item) { // Keep result of constant function - double *dp = (double*)PlugSubAlloc(g, NULL, sizeof(double)); - *dp = d; - g->Activityp = (PACTIVITY)dp; + double *dp; + + if ((dp = (double*)PlgDBSubAlloc(g, NULL, sizeof(double)))) { + *dp = d; + g->Activityp = (PACTIVITY)dp; + } else { + PUSH_WARNING(g->Message); + *is_null = 1; + return 0.0; + } // endif dp + } // endif const_item return d; @@ -3501,7 +3772,7 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error) { - char *p, *path = NULL; + char *path = NULL; int k; PJVAL jvp, jvp2; PJSON jsp; @@ -3529,16 +3800,20 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result, *error = 1; goto err; } else - jvp = MakeValue(g, args, 0); - - if ((p = jvp->GetString(g))) { - if (!(jsp = ParseJson(g, p, strlen(p)))) { - PUSH_WARNING(g->Message); - goto err; - } // endif jsp - - } else - jsp = jvp->GetJson(); + jvp = MakeTypedValue(g, args, 0, TYPE_JSON); + + //if ((p = jvp->GetString(g))) { + // if (!(jsp = ParseJson(g, p, strlen(p)))) { + // PUSH_WARNING(g->Message); + // goto err; + // } // endif jsp + //} else + // jsp = jvp->GetJson(); + + if (!(jsp = jvp->GetJson())) { + PUSH_WARNING("First argument is not a valid JSON item"); + goto err; + } // endif jsp if (g->Mrr) { // First argument is a constant g->Xchk = jsp; @@ -3561,7 +3836,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result, g->Activityp = (PACTIVITY)path; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); PUSH_WARNING(g->Message); @@ -3686,7 +3961,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result, g->Activityp = (PACTIVITY)path; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); PUSH_WARNING(g->Message); @@ -3845,9 +4120,9 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g)JSNX(g, jsp, TYPE_BIGINT); + jsx = JsnxNew(g, jsp, TYPE_BIGINT); - if (jsx->SetJpath(g, path)) { + if (!jsx || jsx->SetJpath(g, path)) { PUSH_WARNING(g->Message); goto err; } // endif SetJpath @@ -3856,9 +4131,14 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result, if (initid->const_item) { // Keep result of constant function - long long *np = (long long*)PlugSubAlloc(g, NULL, sizeof(long long)); - *np = n; - g->Activityp = (PACTIVITY)np; + long long *np = (long long*)PlgDBSubAlloc(g, NULL, sizeof(long long)); + + if (np) { + *np = n; + g->Activityp = (PACTIVITY)np; + } else + PUSH_WARNING(g->Message); + } // endif const_item return n; @@ -3961,7 +4241,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, g->Activityp = (PACTIVITY)str; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); PUSH_WARNING(g->Message); @@ -4335,18 +4615,23 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!bsp || bsp->Changed) { if (!CheckMemory(g, initid, args, args->arg_count, false)) { - PJAR arp = new(g) JARRAY; + PJAR arp; - bsp = JbinAlloc(g, args, initid->max_length, arp); - strcat(bsp->Msg, " array"); + if ((arp = (PJAR)JsonNew(g, TYPE_JAR)) && + (bsp = JbinAlloc(g, args, initid->max_length, arp))) { + strcat(bsp->Msg, " array"); - for (uint i = 0; i < args->arg_count; i++) - arp->AddValue(g, MakeValue(g, args, i)); + for (uint i = 0; i < args->arg_count; i++) + arp->AddValue(g, MakeValue(g, args, i)); + + arp->InitArray(g); + } // endif arp && bsp - arp->InitArray(g); } else - if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, 139); + bsp = NULL; + + if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL))) + strncpy(bsp->Msg, g->Message, 139); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -4377,9 +4662,6 @@ my_bool jbin_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *messa if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); return true; - } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { - strcpy(message, "First argument must be a json string or item"); - return true; } else CalcLen(args, false, reslen, memlen); @@ -4394,24 +4676,17 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!bsp || bsp->Changed) { if (!CheckMemory(g, initid, args, args->arg_count, true)) { - char *p; PJSON top; PJAR arp; - PJVAL jvp = MakeValue(g, args, 0, &top); + PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JAR, &top); PGLOBAL gb = GetMemPtr(g, args, 0); - if ((p = jvp->GetString(g))) { - if (!(top = ParseJson(g, p, strlen(p)))) { - PUSH_WARNING(g->Message); - return NULL; - } // endif jsp - - jvp->SetValue(top); - } // endif p - if (jvp->GetValType() != TYPE_JAR) { - arp = new(gb)JARRAY; - arp->AddValue(gb, jvp); + if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) { + arp->AddValue(gb, jvp); + top = arp; + } // endif arp + } else arp = jvp->GetArray(); @@ -4458,9 +4733,9 @@ my_bool jbin_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); return true; - } else if (!IsJson(args, 0)) { - strcpy(message, "First argument must be a json item"); - return true; + //} else if (!IsJson(args, 0)) { + // strcpy(message, "First argument must be a json item"); + // return true; } else CalcLen(args, false, reslen, memlen, true); @@ -4488,20 +4763,32 @@ char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result, PJVAL jvp; PJAR arp; - jvp = MakeValue(g, args, 0, &top); -// jsp = jvp->GetJson(); + jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top); + // jsp = jvp->GetJson(); x = GetIntArgPtr(g, args, n); if (CheckPath(g, args, top, jvp, n)) PUSH_WARNING(g->Message); - else if (jvp && jvp->GetValType() == TYPE_JAR) { + else if (jvp) { PGLOBAL gb = GetMemPtr(g, args, 0); - arp = jvp->GetArray(); + if (jvp->GetValType() != TYPE_JAR) { + if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) { + arp->AddValue(gb, (PJVAL)JvalNew(gb, TYPE_JVAL, jvp)); + jvp->SetValue(arp); + + if (!top) + top = arp; + + } // endif arp + + } else + arp = jvp->GetArray(); + arp->AddValue(gb, MakeValue(gb, args, 1), x); arp->InitArray(gb); } else { - PUSH_WARNING("First argument is not an array"); + PUSH_WARNING("First argument target is not an array"); // if (g->Mrr) *error = 1; (only if no path) } // endif jvp @@ -4539,9 +4826,6 @@ my_bool jbin_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) if (args->arg_count < 2) { strcpy(message, "This function must have at least 2 arguments"); return true; - } else if (!IsJson(args, 0)) { - strcpy(message, "First argument must be a json item"); - return true; } else CalcLen(args, false, reslen, memlen, true); @@ -4565,7 +4849,7 @@ char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, int *x; uint n = 1; PJAR arp; - PJVAL jvp = MakeValue(g, args, 0, &top); + PJVAL jvp = MakeTypedValue(g, args, 0, TYPE_JSON, &top); if (CheckPath(g, args, top, jvp, 1)) PUSH_WARNING(g->Message); @@ -4578,8 +4862,8 @@ char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, PUSH_WARNING("Missing or null array index"); } else { - PUSH_WARNING("First argument is not an array"); - if (g->Mrr) *error = 1; + PUSH_WARNING("First argument target is not an array"); +// if (g->Mrr) *error = 1; } // endif jvp } // endif CheckMemory @@ -4625,13 +4909,18 @@ char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!bsp || bsp->Changed) { if (!CheckMemory(g, initid, args, args->arg_count, true)) { - PJOB objp = new(g)JOBJECT; + PJOB objp; - for (uint i = 0; i < args->arg_count; i++) - objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i)); + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i++) + objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i)); + + + if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) + strcat(bsp->Msg, " object"); - if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) - strcat(bsp->Msg, " object"); + } else + bsp = NULL; } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) @@ -4676,14 +4965,18 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!bsp || bsp->Changed) { if (!CheckMemory(g, initid, args, args->arg_count, false, true)) { PJVAL jvp; - PJOB objp = new(g)JOBJECT; + PJOB objp; - for (uint i = 0; i < args->arg_count; i++) - if (!(jvp = MakeValue(g, args, i))->IsNull()) - objp->SetValue(g, jvp, MakeKey(g, args, i)); + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i++) + if (!(jvp = MakeValue(g, args, i))->IsNull()) + objp->SetValue(g, jvp, MakeKey(g, args, i)); - if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) - strcat(bsp->Msg, " object"); + if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) + strcat(bsp->Msg, " object"); + + } else + bsp = NULL; } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) @@ -4732,13 +5025,17 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!bsp || bsp->Changed) { if (!CheckMemory(g, initid, args, args->arg_count, false, true)) { - PJOB objp = new(g)JOBJECT; + PJOB objp; + + if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) { + for (uint i = 0; i < args->arg_count; i += 2) + objp->SetValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i)); - for (uint i = 0; i < args->arg_count; i += 2) - objp->SetValue(g, MakeValue(g, args, i+1), MakePSZ(g, args, i)); + if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) + strcat(bsp->Msg, " object"); - if ((bsp = JbinAlloc(g, args, initid->max_length, objp))) - strcat(bsp->Msg, " object"); + } else + bsp = NULL; } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) @@ -4989,7 +5286,7 @@ my_bool jbin_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error) { - char *p, *path; + char *path; PJSON jsp; PJSNX jsx; PJVAL jvp; @@ -5006,17 +5303,10 @@ char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, if (CheckMemory(g, initid, args, 1, true, true)) { PUSH_WARNING("CheckMemory error"); goto fin; - } else - jvp = MakeValue(g, args, 0); - - if ((p = jvp->GetString(g))) { - if (!(jsp = ParseJson(g, p, strlen(p)))) { - PUSH_WARNING(g->Message); - goto fin; - } // endif jsp + } // endif CheckMemory - } else - jsp = jvp->GetJson(); + jvp = MakeTypedValue(g, args, 0, TYPE_JSON); + jsp = jvp->GetJson(); if (g->Mrr) { // First argument is a constant g->Xchk = jsp; @@ -5027,16 +5317,16 @@ char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, jsp = (PJSON)g->Xchk; path = MakePSZ(g, args, 1); - jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length); + jsx = JsnxNew(g, jsp, TYPE_STRING, initid->max_length); - if (jsx->SetJpath(g, path, false)) { + if (!jsx || jsx->SetJpath(g, path, false)) { PUSH_WARNING(g->Message); goto fin; } // endif SetJpath // Get the json tree if ((jvp = jsx->GetRowValue(g, jsp, 0, false))) { - jsp = (jvp->GetJsp()) ? jvp->GetJsp() : new(g) JVALUE(g, jvp->GetValue()); + jsp = (jvp->GetJsp()) ? jvp->GetJsp() : JvalNew(g, TYPE_VAL, jvp->GetValue()); if ((bsp = JbinAlloc(g, args, initid->max_length, jsp))) strcat(bsp->Msg, " item"); diff --git a/storage/connect/jsonudf.h b/storage/connect/jsonudf.h index cd3b9768f7a80ec09952f8e32649e32da9cd06b6..23e8c0e1aed2ea1a760fd63d063aa7d65203caa4 100644 --- a/storage/connect/jsonudf.h +++ b/storage/connect/jsonudf.h @@ -89,6 +89,10 @@ extern "C" { DllExport char *json_object_list(UDF_EXEC_ARGS); DllExport void json_object_list_deinit(UDF_INIT*); + DllExport my_bool json_object_values_init(UDF_INIT*, UDF_ARGS*, char*); + DllExport char *json_object_values(UDF_EXEC_ARGS); + DllExport void json_object_values_deinit(UDF_INIT*); + DllExport my_bool jsonset_grp_size_init(UDF_INIT*, UDF_ARGS*, char*); DllExport long long jsonset_grp_size(UDF_INIT*, UDF_ARGS*, char*, char*); diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 700d247da38ff5058e758106a959922a4dd6f005..9b30b315441e6ed58256e09ef83a9ec8d8f69c0b 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -194,7 +194,7 @@ void xtrc(char const *fmt, ...) { va_list ap; va_start (ap, fmt); - + ; //vfprintf(stderr, fmt, ap); vsprintf(s, fmt, ap); if (s[strlen(s)-1] == '\n') @@ -210,7 +210,7 @@ static xmlStrdupFunc Strdup; void xmlMyFree(void *mem) { - if (trace) { + if (trace(1)) { htrc("%.4d Freeing at %p %s\n", ++m, mem, s); *s = 0; } // endif trace @@ -220,7 +220,7 @@ void xmlMyFree(void *mem) void *xmlMyMalloc(size_t size) { void *p = Malloc(size); - if (trace) { + if (trace(1)) { htrc("%.4d Allocating %.5d at %p %s\n", ++m, size, p, s); *s = 0; } // endif trace @@ -230,7 +230,7 @@ void *xmlMyMalloc(size_t size) void *xmlMyMallocAtomic(size_t size) { void *p = MallocA(size); - if (trace) { + if (trace(1)) { htrc("%.4d Atom alloc %.5d at %p %s\n", ++m, size, p, s); *s = 0; } // endif trace @@ -240,7 +240,7 @@ void *xmlMyMallocAtomic(size_t size) void *xmlMyRealloc(void *mem, size_t size) { void *p = Realloc(mem, size); - if (trace) { + if (trace(1)) { htrc("%.4d ReAlloc %.5d to %p from %p %s\n", ++m, size, p, mem, s); *s = 0; } // endif trace @@ -250,7 +250,7 @@ void *xmlMyRealloc(void *mem, size_t size) char *xmlMyStrdup(const char *str) { char *p = Strdup(str); - if (trace) { + if (trace(1)) { htrc("%.4d Duplicating to %p from %p %s %s\n", ++m, p, str, str, s); *s = 0; } // endif trace @@ -339,7 +339,7 @@ void CloseXML2File(PGLOBAL g, PFBLOCK fp, bool all) { PX2BLOCK xp = (PX2BLOCK)fp; - if (trace) + if (trace(1)) htrc("CloseXML2File: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); if (xp && xp->Count > 1 && !all) { @@ -387,7 +387,7 @@ bool LIBXMLDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped) /******************************************************************/ bool LIBXMLDOC::ParseFile(PGLOBAL g, char *fn) { - if (trace) + if (trace(1)) htrc("ParseFile\n"); if (zip) { @@ -436,7 +436,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn) /******************************************************************/ bool LIBXMLDOC::NewDoc(PGLOBAL g, PCSZ ver) { - if (trace) + if (trace(1)) htrc("NewDoc\n"); return ((Docp = xmlNewDoc(BAD_CAST ver)) == NULL); @@ -447,7 +447,7 @@ bool LIBXMLDOC::NewDoc(PGLOBAL g, PCSZ ver) /******************************************************************/ void LIBXMLDOC::AddComment(PGLOBAL g, char *txtp) { - if (trace) + if (trace(1)) htrc("AddComment: %s\n", txtp); xmlNodePtr cp = xmlNewDocComment(Docp, BAD_CAST txtp); @@ -459,7 +459,7 @@ void LIBXMLDOC::AddComment(PGLOBAL g, char *txtp) /******************************************************************/ PXNODE LIBXMLDOC::GetRoot(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("GetRoot\n"); xmlNodePtr root = xmlDocGetRootElement(Docp); @@ -475,7 +475,7 @@ PXNODE LIBXMLDOC::GetRoot(PGLOBAL g) /******************************************************************/ PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) { - if (trace) + if (trace(1)) htrc("NewRoot: %s\n", name); xmlNodePtr root = xmlNewDocNode(Docp, NULL, BAD_CAST name, NULL); @@ -493,7 +493,7 @@ PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) /******************************************************************/ PXNODE LIBXMLDOC::NewPnode(PGLOBAL g, char *name) { - if (trace) + if (trace(1)) htrc("NewNode: %s\n", name); xmlNodePtr nop; @@ -534,7 +534,7 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) int rc = 0; FILE *of; - if (trace) + if (trace(1)) htrc("DumpDoc: %s\n", ofn); if (!(of= global_fopen(g, MSGID_CANNOT_OPEN, ofn, "w"))) @@ -576,7 +576,7 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) /******************************************************************/ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp) { - if (trace) + if (trace(1)) htrc("CloseDoc: xp=%p count=%d\n", xp, (xp) ? xp->Count : 0); //if (xp && xp->Count == 1) { @@ -630,24 +630,24 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) { xmlNodeSetPtr nl; - if (trace) + if (trace(1)) htrc("GetNodeList: %s np=%p\n", xp, np); if (!Ctxp) { // Init Xpath - if (trace) + if (trace(1)) htrc("Calling xmlPathInit\n"); xmlXPathInit(); - if (trace) + if (trace(1)) htrc("Calling xmlXPathNewContext Docp=%p\n", Docp); // Create xpath evaluation context if (!(Ctxp = xmlXPathNewContext(Docp))) { strcpy(g->Message, MSG(XPATH_CNTX_ERR)); - if (trace) + if (trace(1)) htrc("Context error: %s\n", g->Message); return NULL; @@ -655,7 +655,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) // Register namespaces from list (if any) for (PNS nsp = Namespaces; nsp; nsp = nsp->Next) { - if (trace) + if (trace(1)) htrc("Calling xmlXPathRegisterNs Prefix=%s Uri=%s\n", nsp->Prefix, nsp->Uri); @@ -663,7 +663,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) BAD_CAST nsp->Uri)) { sprintf(g->Message, MSG(REGISTER_ERR), nsp->Prefix, nsp->Uri); - if (trace) + if (trace(1)) htrc("Ns error: %s\n", g->Message); return NULL; @@ -674,7 +674,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) } // endif Ctxp if (Xop) { - if (trace) + if (trace(1)) htrc("Calling xmlXPathFreeNodeSetList Xop=%p NOFREE=%d\n", Xop, Nofreelist); @@ -698,21 +698,21 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) // Set the context to the calling node Ctxp->node = np; - if (trace) + if (trace(1)) htrc("Calling xmlXPathEval %s Ctxp=%p\n", xp, Ctxp); // Evaluate table xpath if (!(Xop = xmlXPathEval(BAD_CAST xp, Ctxp))) { sprintf(g->Message, MSG(XPATH_EVAL_ERR), xp); - if (trace) + if (trace(1)) htrc("Path error: %s\n", g->Message); return NULL; } else nl = Xop->nodesetval; - if (trace) + if (trace(1)) htrc("GetNodeList nl=%p n=%p\n", nl, (nl) ? nl->nodeNr : 0); return nl; @@ -811,7 +811,7 @@ XML2NODE::XML2NODE(PXDOC dp, xmlNodePtr np) : XMLNODE(dp) int XML2NODE::GetType(void) { - if (trace) + if (trace(1)) htrc("GetType type=%d\n", Nodep->type); return Nodep->type; @@ -822,7 +822,7 @@ int XML2NODE::GetType(void) /******************************************************************/ PXNODE XML2NODE::GetNext(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("GetNext\n"); if (!Nodep->next) @@ -838,7 +838,7 @@ PXNODE XML2NODE::GetNext(PGLOBAL g) /******************************************************************/ PXNODE XML2NODE::GetChild(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("GetChild\n"); if (!Nodep->children) @@ -856,7 +856,7 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) { RCODE rc = RC_OK; - if (trace) + if (trace(1)) htrc("GetContent\n"); if (Content) @@ -888,7 +888,7 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) *p2 = 0; - if (trace) + if (trace(1)) htrc("GetText buf='%s' len=%d\n", buf, len); xmlFree(Content); @@ -896,7 +896,7 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) } else *buf = '\0'; - if (trace) + if (trace(1)) htrc("GetContent: %s\n", buf); return rc; @@ -907,12 +907,12 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) /******************************************************************/ bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) { - if (trace) + if (trace(1)) htrc("SetContent: %s\n", txtp); xmlChar *buf = xmlEncodeEntitiesReentrant(Docp, BAD_CAST txtp); - if (trace) + if (trace(1)) htrc("SetContent: %s -> %s\n", txtp, buf); xmlNodeSetContent(Nodep, buf); @@ -925,7 +925,7 @@ bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) /******************************************************************/ PXNODE XML2NODE::Clone(PGLOBAL g, PXNODE np) { - if (trace) + if (trace(1)) htrc("Clone: np=%p\n", np); if (np) { @@ -941,7 +941,7 @@ PXNODE XML2NODE::Clone(PGLOBAL g, PXNODE np) /******************************************************************/ PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) { - if (trace) + if (trace(1)) htrc("GetChildElements: %s\n", xp); return SelectNodes(g, (xp) ? xp : (char*)"*", lp); @@ -952,7 +952,7 @@ PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) /******************************************************************/ PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) { - if (trace) + if (trace(1)) htrc("SelectNodes: %s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -970,7 +970,7 @@ PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) /******************************************************************/ PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) { - if (trace) + if (trace(1)) htrc("SelectSingleNode: %s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -994,7 +994,7 @@ PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) { xmlAttrPtr atp; - if (trace) + if (trace(1)) htrc("GetAttribute: %s\n", SVP(name)); if (name) @@ -1023,7 +1023,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np) { char *p, *pn, *pf = NULL, *nmp = PlugDup(g, name); - if (trace) + if (trace(1)) htrc("AddChildNode: %s\n", name); // Is a prefix specified @@ -1074,7 +1074,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np) /******************************************************************/ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) { - if (trace) + if (trace(1)) htrc("AddProperty: %s\n", name); xmlAttrPtr atp = xmlNewProp(Nodep, BAD_CAST name, NULL); @@ -1097,7 +1097,7 @@ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) /******************************************************************/ void XML2NODE::AddText(PGLOBAL g, PCSZ txtp) { - if (trace) + if (trace(1)) htrc("AddText: %s\n", txtp); // This is to avoid a blank line when inserting a new line @@ -1119,7 +1119,7 @@ void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp) { xmlErrorPtr xerr; - if (trace) + if (trace(1)) htrc("DeleteChild: node=%p\n", dnp); xmlNodePtr np = ((PNODE2)dnp)->Nodep; @@ -1157,7 +1157,7 @@ void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp) return; err: - if (trace) + if (trace(1)) htrc("DeleteChild: errmsg=%s\n", xerr->message); xmlResetError(xerr); @@ -1187,7 +1187,7 @@ int XML2NODELIST::GetLength(void) /******************************************************************/ PXNODE XML2NODELIST::GetItem(PGLOBAL g, int n, PXNODE np) { - if (trace) + if (trace(1)) htrc("GetItem: %d\n", n); if (!Listp || Listp->nodeNr <= n) @@ -1206,7 +1206,7 @@ PXNODE XML2NODELIST::GetItem(PGLOBAL g, int n, PXNODE np) /******************************************************************/ bool XML2NODELIST::DropItem(PGLOBAL g, int n) { - if (trace) + if (trace(1)) htrc("DropItem: n=%d\n", n); // We should do something here @@ -1234,7 +1234,7 @@ XML2ATTR::XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np) /******************************************************************/ PXATTR XML2ATTR::GetNext(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("Attr GetNext\n"); if (!Atrp->next) @@ -1252,7 +1252,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) RCODE rc = RC_OK; xmlChar *txt; - if (trace) + if (trace(1)) htrc("GetText\n"); if ((txt = xmlGetProp(Atrp->parent, Atrp->name))) { @@ -1269,7 +1269,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) } else *buf = '\0'; - if (trace) + if (trace(1)) htrc("GetText: %s\n", buf); return rc; @@ -1280,7 +1280,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) /******************************************************************/ bool XML2ATTR::SetText(PGLOBAL g, char *txtp, int len) { - if (trace) + if (trace(1)) htrc("SetText: %s %d\n", txtp, len); xmlSetProp(Parent, Atrp->name, BAD_CAST txtp); diff --git a/storage/connect/macutil.cpp b/storage/connect/macutil.cpp index b9600bdac2e5da46ee6ac3dd741702e6073e2bd7..f95f3adcc6edcf62e778c0682a7c6f71d4ccecfd 100644 --- a/storage/connect/macutil.cpp +++ b/storage/connect/macutil.cpp @@ -230,13 +230,13 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv) case 11: // Description if ((p = strstr(Curp->Description, " - Packet Scheduler Miniport"))) { strncpy(buf, Curp->Description, p - Curp->Description); - i = p - Curp->Description; + i = (int)(p - Curp->Description); strncpy(buf, Curp->Description, i); buf[i] = 0; p = buf; } else if ((p = strstr(Curp->Description, " - Miniport d'ordonnancement de paquets"))) { - i = p - Curp->Description; + i = (int)(p - Curp->Description); strncpy(buf, Curp->Description, i); buf[i] = 0; p = buf; diff --git a/storage/connect/mongo.cpp b/storage/connect/mongo.cpp index 088dc2d29d1788f71af5f29ab57754b584718f29..53e2bf377c43c52937d7f67541025ca34e23a753 100644 --- a/storage/connect/mongo.cpp +++ b/storage/connect/mongo.cpp @@ -172,7 +172,7 @@ PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info) goto err; skipit: - if (trace) + if (trace(1)) htrc("MGOColumns: n=%d len=%d\n", n, length[0]); /*********************************************************************/ @@ -276,7 +276,7 @@ int MGODISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt) tdp->Wrapname = (PSZ)GetStringTableOption(g, topt, "Wrapper", (tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface"); - if (trace) + if (trace(1)) htrc("Uri %s coll=%s db=%s colist=%s filter=%s lvl=%d\n", tdp->Uri, tdp->Tabname, tdp->Tabschema, tdp->Colist, tdp->Filter, lvl); diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index bb77512be62efe4885bdd08466190184538319cd..cc8f75b297603fe42b85f1dce705dac44390bfc8 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -94,9 +94,9 @@ #if defined(XML_SUPPORT) #include "tabxml.h" #endif // XML_SUPPORT -#if defined(JAVA_SUPPORT) +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) #include "mongo.h" -#endif // JAVA_SUPPORT +#endif // JAVA_SUPPORT || CMGO_SUPPORT #if defined(ZIP_SUPPORT) #include "tabzip.h" #endif // ZIP_SUPPORT @@ -109,9 +109,10 @@ extern "C" HINSTANCE s_hModule; // Saved module handle #endif // !__WIN__ -#if defined(JAVA_SUPPORT) -//bool MongoEnabled(void); -#endif // JAVA_SUPPORT +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) +bool MongoEnabled(void); +#endif // JAVA_SUPPORT || CMGO_SUPPORT + PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ @@ -145,6 +146,9 @@ TABTYPE GetTypeID(const char *type) #if defined(JAVA_SUPPORT) : (!stricmp(type, "JDBC")) ? TAB_JDBC : (!stricmp(type, "MONGO")) ? TAB_MONGO +#endif +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) + : (!stricmp(type, "MONGO") && MongoEnabled()) ? TAB_MONGO #endif : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL @@ -488,7 +492,7 @@ void MYCAT::Reset(void) PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR type, PRELDEF *) { - if (trace) + if (trace(1)) printf("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type)); // If not specified get the type of this table @@ -509,7 +513,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) LPCSTR schema = (PSZ)PlugDup(g, tablep->GetSchema()); PRELDEF tdp= NULL; - if (trace) + if (trace(1)) printf("MakeTableDesc: name=%s schema=%s am=%s\n", name, SVP(schema), SVP(am)); @@ -562,8 +566,16 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) break; #endif // MONGO_SUPPORT #if defined(ZIP_SUPPORT) - case TAB_ZIP: tdp= new(g) ZIPDEF; break; + case TAB_ZIP: tdp = new(g) ZIPDEF; break; #endif // ZIP_SUPPORT +#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) + case TAB_MONGO: + if (MongoEnabled()) { + tdp = new(g) MGODEF; + break; + } // endif enabled + // fall through +#endif // JAVA_SUPPORT || CMGO_SUPPORT default: sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); } // endswitch @@ -584,14 +596,14 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) PTDB tdbp= NULL; // LPCSTR name= tablep->GetName(); - if (trace) + if (trace(1)) printf("GetTableDB: name=%s\n", tablep->GetName()); // Look for the description of the requested table tdp= GetTableDesc(g, tablep, type); if (tdp) { - if (trace) + if (trace(1)) printf("tdb=%p type=%s\n", tdp, tdp->GetType()); if (tablep->GetSchema()) @@ -601,7 +613,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) } // endif tdp if (tdbp) { - if (trace) + if (trace(1)) printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), tdbp->GetAmType()); tablep->SetTo_Tdb(tdbp); diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index fe00f6a1eab007b0853769483538aad270f66596..253c42bb0022fb1b3500beccac160f417f673a8d 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -177,7 +177,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, return NULL; } // endif b - if (trace) + if (trace(1)) htrc("MyColumns: cmd='%s'\n", cmd.GetStr()); if ((n = myc.GetResultSize(g, cmd.GetStr())) < 0) { @@ -248,7 +248,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, while (true) { p2 = strchr(p1, '\''); - len = MY_MAX(len, p2 - p1); + len = MY_MAX(len, (int)(p2 - p1)); if (*++p2 != ',') break; p1 = p2 + 2; } // endwhile @@ -482,7 +482,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, return RC_FX; } // endif m_DB - if (trace) + if (trace(1)) htrc("MYSQLC Open: m_DB=%.4X size=%d\n", m_DB, (int)sizeof(*m_DB)); // Removed to do like FEDERATED do @@ -744,7 +744,7 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w) m_Fields = mysql_num_fields(m_Res); m_Rows = (!m_Use) ? (int)mysql_num_rows(m_Res) : 0; - if (trace) + if (trace(1)) htrc("ExecSQL: m_Res=%.4X size=%d m_Fields=%d m_Rows=%d\n", m_Res, sizeof(*m_Res), m_Fields, m_Rows); @@ -1068,7 +1068,7 @@ void MYSQLC::Close(void) { FreeResult(); - if (trace) + if (trace(1)) htrc("MYSQLC Close: m_DB=%.4X\n", m_DB); mysql_close(m_DB); diff --git a/storage/connect/mysql-test/connect/r/jdbc_postgresql.result b/storage/connect/mysql-test/connect/r/jdbc_postgresql.result index 6d77d79d5d3ffbbbf75dd0afd4039c474486c2b5..7969672dd6688016b5fe517ddb323ff0e30c7120 100644 --- a/storage/connect/mysql-test/connect/r/jdbc_postgresql.result +++ b/storage/connect/mysql-test/connect/r/jdbc_postgresql.result @@ -1,9 +1,11 @@ +SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar;C:/Jconnectors/postgresql-42.2.1.jar'; CREATE TABLE t2 ( command varchar(128) not null, number int(5) not null flag=1, message varchar(255) flag=2) -ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:postgresql://localhost/mtr' -OPTION_LIST='User=mtr,Password=mtr,Schema=public,Execsrc=1'; +ENGINE=CONNECT TABLE_TYPE=JDBC +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' +OPTION_LIST='Execsrc=1'; SELECT * FROM t2 WHERE command='drop table employee'; command number message drop table employee 0 Execute: org.postgresql.util.PSQLException: ERREUR: la table « employee » n'existe pas @@ -14,17 +16,18 @@ SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'E command number message insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables -CONNECTION='jdbc:postgresql://localhost/mtr' -OPTION_LIST='User=mtr,Password=mtr,Schema=public,Tabtype=TABLE,Maxres=10'; +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' +OPTION_LIST='Tabtype=TABLE,Maxres=10'; SELECT * FROM t1; Table_Cat Table_Schema Table_Name Table_Type Remark - public employee TABLE NULL - public t1 TABLE NULL - public t2 TABLE NULL +NULL public employee TABLE NULL +NULL public t1 TABLE NULL +NULL public t2 TABLE NULL +NULL public tchar TABLE NULL +NULL public testuuid TABLE NULL DROP TABLE t1; -CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=columns -CONNECTION='jdbc:postgresql://localhost/mtr' tabname=employee -OPTION_LIST='User=mtr,Password=mtr,Maxres=10'; +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC tabname=employee CATFUNC=columns +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono'; SELECT * FROM t1; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks NULL public employee id 4 int4 10 0 0 10 0 NULL @@ -34,13 +37,14 @@ NULL public employee salary 2 numeric 8 0 2 10 1 NULL DROP TABLE t1; CREATE SERVER 'postgresql' FOREIGN DATA WRAPPER 'postgresql' OPTIONS ( HOST 'localhost', -DATABASE 'mtr', -USER 'mtr', -PASSWORD 'mtr', +DATABASE 'test', +USER 'postgres', +PASSWORD 'tinono', PORT 0, SOCKET '', OWNER 'root'); -CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='postgresql/public.employee'; +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC +CONNECTION='postgresql/public.employee'; SELECT * FROM t1; id name title salary 4567 Johnson Engineer 12560.50 @@ -60,6 +64,3 @@ SELECT * FROM t2 WHERE command='drop table employee'; command number message drop table employee 0 Affected rows DROP TABLE t2; -SET GLOBAL connect_jvm_path=NULL; -SET GLOBAL connect_class_path=NULL; -SET GLOBAL time_zone = SYSTEM; diff --git a/storage/connect/mysql-test/connect/r/json_java_2.result b/storage/connect/mysql-test/connect/r/json_java_2.result index 783d86e6595e418d896269fe9704217692730027..1a90132deded347e2de42c28c01e8e91ac7936e4 100644 --- a/storage/connect/mysql-test/connect/r/json_java_2.result +++ b/storage/connect/mysql-test/connect/r/json_java_2.result @@ -1,4 +1,5 @@ -SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -381,3 +382,7 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +<<<<<<< HEAD +======= +set connect_enable_mongo=0; +>>>>>>> connect/10.0 diff --git a/storage/connect/mysql-test/connect/r/json_java_3.result b/storage/connect/mysql-test/connect/r/json_java_3.result index a301e0273d518c5197e52438982c00eabce3bd12..4c5fc94fca62910726aa9bf37a18b1635da356a5 100644 --- a/storage/connect/mysql-test/connect/r/json_java_3.result +++ b/storage/connect/mysql-test/connect/r/json_java_3.result @@ -1,4 +1,5 @@ -SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -381,3 +382,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/json_mongo_c.result b/storage/connect/mysql-test/connect/r/json_mongo_c.result index 8adc006a51bb938fd9005ded3fd5933b8f51fd63..550e94f286e39f4b10d4da964f4470f3492b014c 100644 --- a/storage/connect/mysql-test/connect/r/json_mongo_c.result +++ b/storage/connect/mysql-test/connect/r/json_mongo_c.result @@ -1,3 +1,4 @@ +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -380,3 +381,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/json_udf.result b/storage/connect/mysql-test/connect/r/json_udf.result index 7d81ca5e73dc2ec6e4e69615184b1c8606253197..09544bb1ecb3bc7a1b86066cb0c0832be8396db5 100644 --- a/storage/connect/mysql-test/connect/r/json_udf.result +++ b/storage/connect/mysql-test/connect/r/json_udf.result @@ -50,17 +50,19 @@ SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Arra Array [56,3.141600,"foo",null,"One more"] SELECT Json_Array_Add(JsonValue('one value'), 'One more'); -ERROR HY000: Can't initialize function 'json_array_add'; First argument must be a json item +Json_Array_Add(JsonValue('one value'), 'One more') +["\"one value\"","One more"] SELECT Json_Array_Add('one value', 'One more'); -ERROR HY000: Can't initialize function 'json_array_add'; First argument must be a json item +Json_Array_Add('one value', 'One more') +["one value","One more"] SELECT Json_Array_Add('one value' json_, 'One more'); Json_Array_Add('one value' json_, 'One more') one value Warnings: Warning 1105 Error 2 opening one value -Warning 1105 First argument target is not an array SELECT Json_Array_Add(5 json_, 'One more'); -ERROR HY000: Can't initialize function 'json_array_add'; First argument must be a json item +Json_Array_Add(5 json_, 'One more') +[5,"One more"] SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0); Json_Array_Add('[5,3,8,7,9]' json_, 4, 0) [4,5,3,8,7,9] diff --git a/storage/connect/mysql-test/connect/r/json_udf_bin.result b/storage/connect/mysql-test/connect/r/json_udf_bin.result index 0c009d612fe2325eaec16ed36005a33e55d1c430..d0819619c33a3f684e2e827e28f64028b2dfe50a 100644 --- a/storage/connect/mysql-test/connect/r/json_udf_bin.result +++ b/storage/connect/mysql-test/connect/r/json_udf_bin.result @@ -272,10 +272,9 @@ Json_Serialize(Jbin_Array('a','b','c')) ["a","b","c"] SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd')); Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd')) -Null json tree +[null,"d"] Warnings: Warning 1105 Open(map) error 2 on not_exist.json -Warning 1105 First argument is not an array # This does not modify the file SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')); Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) diff --git a/storage/connect/mysql-test/connect/r/mongo_c.result b/storage/connect/mysql-test/connect/r/mongo_c.result index c7aadcf116591d48e81aba3fb84eec0491668426..132bb34ce648b3108218a9384f720b0806c021a2 100644 --- a/storage/connect/mysql-test/connect/r/mongo_c.result +++ b/storage/connect/mysql-test/connect/r/mongo_c.result @@ -1,3 +1,4 @@ +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -376,3 +377,4 @@ planner 167 41.750000 postcard 23 5.750000 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/mongo_java_2.result b/storage/connect/mysql-test/connect/r/mongo_java_2.result index 708b6f1cc7c7c021d3928baaea6948ec44a56398..67c67653e88dda71ab9279bfe399d2cd39011ba4 100644 --- a/storage/connect/mysql-test/connect/r/mongo_java_2.result +++ b/storage/connect/mysql-test/connect/r/mongo_java_2.result @@ -1,4 +1,5 @@ -SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -377,3 +378,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/mongo_java_3.result b/storage/connect/mysql-test/connect/r/mongo_java_3.result index 672d9f15b809b12a155341ef826618d50229b069..665178bd3ea047ec78f46c7e8c9eeedb2077616d 100644 --- a/storage/connect/mysql-test/connect/r/mongo_java_3.result +++ b/storage/connect/mysql-test/connect/r/mongo_java_3.result @@ -1,4 +1,5 @@ -SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -377,3 +378,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/tbl_thread.result b/storage/connect/mysql-test/connect/r/tbl_thread.result index e07fc0988fd12023f761b6d6ae477569b279d876..9633f358c97ad332f9f2d778d0b531535316fceb 100644 --- a/storage/connect/mysql-test/connect/r/tbl_thread.result +++ b/storage/connect/mysql-test/connect/r/tbl_thread.result @@ -79,7 +79,7 @@ a b CREATE TABLE total (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5' OPTION_LIST='thread=yes,port=PORT'; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by a desc; a b 19 test19 @@ -118,7 +118,7 @@ SELECT * FROM t2; v 22 CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by v desc; v 22 @@ -137,7 +137,7 @@ SELECT * FROM t2; v 22 CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by v desc; v 22 diff --git a/storage/connect/mysql-test/connect/r/vcol.result b/storage/connect/mysql-test/connect/r/vcol.result new file mode 100644 index 0000000000000000000000000000000000000000..4c59a3b06d8406c3791ea3c6c14fb9d82305f66c --- /dev/null +++ b/storage/connect/mysql-test/connect/r/vcol.result @@ -0,0 +1,29 @@ +create table t1 ( +#linenum int(6) not null default 0 special=rowid, +name char(12) not null, +city char(11) not null, +birth date not null date_format='DD/MM/YYYY', +hired date not null date_format='DD/MM/YYYY' flag=36, +agehired int(3) as (floor(datediff(hired,birth)/365.25)) +) +engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1; +select * from t1; +name city birth hired agehired +John Boston 1986-01-25 2010-06-02 24 +Henry Boston 1987-06-07 2008-04-01 20 +George San Jose 1981-08-10 2010-06-02 28 +Sam Chicago 1979-11-22 2007-10-10 27 +James Dallas 1992-05-13 2009-12-14 17 +Bill Boston 1986-09-11 2008-02-10 21 +drop table t1; +create table t1 ( +#linenum int(6) not null default 0 special=rowid, +name char(12) not null, +city char(11) not null, +birth date not null date_format='DD/MM/YYYY', +hired date not null date_format='DD/MM/YYYY' flag=36, +agehired int(3) as (floor(datediff(hired,birth)/365.25)), +index (agehired) +) +engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1; +ERROR HY000: Key/Index cannot be defined on a non-stored computed column diff --git a/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar b/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar new file mode 100644 index 0000000000000000000000000000000000000000..33b29e7685b66ee03d1b3f5921f2ba32d48f76b3 Binary files /dev/null and b/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar differ diff --git a/storage/connect/mysql-test/connect/std_data/Mongo2.jar b/storage/connect/mysql-test/connect/std_data/Mongo2.jar index d019bf6906b7af900f676a919885a9f2e440af88..9be654bd4c8e2a1a3fd159c2a69acb5acc55011c 100644 Binary files a/storage/connect/mysql-test/connect/std_data/Mongo2.jar and b/storage/connect/mysql-test/connect/std_data/Mongo2.jar differ diff --git a/storage/connect/mysql-test/connect/std_data/Mongo3.jar b/storage/connect/mysql-test/connect/std_data/Mongo3.jar index 21c6c2d10bdf50c4389f0aeb0dac75c36b0ed9ac..2850177a66899d799fb171f30727ed05b906ebfc 100644 Binary files a/storage/connect/mysql-test/connect/std_data/Mongo3.jar and b/storage/connect/mysql-test/connect/std_data/Mongo3.jar differ diff --git a/storage/connect/mysql-test/connect/t/jdbc_postgresql.test b/storage/connect/mysql-test/connect/t/jdbc_postgresql.test index 1041ef468d7b82fc69d43c1be251a832899acc85..8036f71020d029b32ff48a47247d4158c0bcaf89 100644 --- a/storage/connect/mysql-test/connect/t/jdbc_postgresql.test +++ b/storage/connect/mysql-test/connect/t/jdbc_postgresql.test @@ -3,25 +3,32 @@ # # This test is run against Postgresql driver # +eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/JavaWrappers.jar;C:/Jconnectors/postgresql-42.2.1.jar'; CREATE TABLE t2 ( command varchar(128) not null, number int(5) not null flag=1, message varchar(255) flag=2) -ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:postgresql://localhost/mtr' -OPTION_LIST='User=mtr,Password=mtr,Schema=public,Execsrc=1'; +ENGINE=CONNECT TABLE_TYPE=JDBC +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' +OPTION_LIST='Execsrc=1'; +#CONNECTION='jdbc:postgresql://localhost/mtr' +#OPTION_LIST='User=mtr,Password=mtr,Schema=public,Execsrc=1'; SELECT * FROM t2 WHERE command='drop table employee'; SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2))'; SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)"; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables -CONNECTION='jdbc:postgresql://localhost/mtr' -OPTION_LIST='User=mtr,Password=mtr,Schema=public,Tabtype=TABLE,Maxres=10'; +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' +OPTION_LIST='Tabtype=TABLE,Maxres=10'; +#CONNECTION='jdbc:postgresql://localhost/mtr' +#OPTION_LIST='User=mtr,Password=mtr,Schema=public,Tabtype=TABLE,Maxres=10'; SELECT * FROM t1; DROP TABLE t1; -CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=columns -CONNECTION='jdbc:postgresql://localhost/mtr' tabname=employee -OPTION_LIST='User=mtr,Password=mtr,Maxres=10'; +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC tabname=employee CATFUNC=columns +CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono'; +#CONNECTION='jdbc:postgresql://localhost/mtr' tabname=employee; +#OPTION_LIST='User=mtr,Password=mtr,Maxres=10'; SELECT * FROM t1; DROP TABLE t1; @@ -30,14 +37,18 @@ DROP TABLE t1; # CREATE SERVER 'postgresql' FOREIGN DATA WRAPPER 'postgresql' OPTIONS ( HOST 'localhost', -DATABASE 'mtr', -USER 'mtr', -PASSWORD 'mtr', +DATABASE 'test', +USER 'postgres', +PASSWORD 'tinono', PORT 0, SOCKET '', OWNER 'root'); +#DATABASE 'mtr', +#USER 'mtr', +#PASSWORD 'mtr', -CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='postgresql/public.employee'; +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC +CONNECTION='postgresql/public.employee'; SELECT * FROM t1; INSERT INTO t1 VALUES(3126,'Smith', 'Clerk', 5230.00); UPDATE t1 SET salary = salary + 100.00; diff --git a/storage/connect/mysql-test/connect/t/jdbconn.inc b/storage/connect/mysql-test/connect/t/jdbconn.inc index 05122f51924c2b94b16177dfdc30b9e66945fd00..81ec80c13d6e910f9c8adbef6fa841375f802a7b 100644 --- a/storage/connect/mysql-test/connect/t/jdbconn.inc +++ b/storage/connect/mysql-test/connect/t/jdbconn.inc @@ -22,10 +22,11 @@ DROP TABLE t1; # 1 - The current directory. # 2 - The paths of the connect_class_path global variable. # 3 - The paths of the CLASSPATH environment variable. -# In this test we use an executable jar file that contains all what is needed. -eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/JdbcMariaDB.jar'; +# In this test we use an executable jar file that contains all the eisting wrappers. +#eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/JdbcMariaDB.jar'; +eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/JavaWrappers.jar'; -# Paths to the JDK classes and to the MySQL and MariaDB drivers can be defined in the CLASSPATH environment variable +# Paths to the JDK classes and to the JDBC drivers should be defined in the CLASSPATH environment variable #CREATE FUNCTION envar RETURNS STRING SONAME 'ha_connect.dll'; #SELECT envar('CLASSPATH'); diff --git a/storage/connect/mysql-test/connect/t/json_udf.test b/storage/connect/mysql-test/connect/t/json_udf.test index 35dbbfed7065ef2779751bdc39d24d9c6ccd3513..d45131f32ba0548856f0348406515dc3cf9ef977 100644 --- a/storage/connect/mysql-test/connect/t/json_udf.test +++ b/storage/connect/mysql-test/connect/t/json_udf.test @@ -29,12 +29,12 @@ SELECT Json_Make_Array(Json_Make_Array(56, 3.1416, 'foo'), TRUE); --error ER_CANT_INITIALIZE_UDF SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL)) Array; SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Array; ---error ER_CANT_INITIALIZE_UDF +#--error ER_CANT_INITIALIZE_UDF SELECT Json_Array_Add(JsonValue('one value'), 'One more'); ---error ER_CANT_INITIALIZE_UDF +#--error ER_CANT_INITIALIZE_UDF SELECT Json_Array_Add('one value', 'One more'); SELECT Json_Array_Add('one value' json_, 'One more'); ---error ER_CANT_INITIALIZE_UDF +#--error ER_CANT_INITIALIZE_UDF SELECT Json_Array_Add(5 json_, 'One more'); SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0); SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 2) Array; diff --git a/storage/connect/mysql-test/connect/t/mongo.inc b/storage/connect/mysql-test/connect/t/mongo.inc index 2d7cbcfa8bd74c78ffbd672883b2f9592a4477c5..fab2ca8413909c9749e573d037a28250b2a76c30 100644 --- a/storage/connect/mysql-test/connect/t/mongo.inc +++ b/storage/connect/mysql-test/connect/t/mongo.inc @@ -1,3 +1,3 @@ -let $MONGO= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongo; -let $MONGOIMPORT= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongoimport; +let $MONGO= C:/Applic/MongoDB/Server/3.6/bin/mongo; +let $MONGOIMPORT= C:/Applic/MongoDB/Server/3.6/bin/mongoimport; diff --git a/storage/connect/mysql-test/connect/t/mongo_test.inc b/storage/connect/mysql-test/connect/t/mongo_test.inc index dfc223e9074a72a5ebe5a2cf08216b58ee597527..357fa55240b65670b5c7f582d844c4596a63303c 100644 --- a/storage/connect/mysql-test/connect/t/mongo_test.inc +++ b/storage/connect/mysql-test/connect/t/mongo_test.inc @@ -1,4 +1,4 @@ -#set connect_enable_mongo=1; +set connect_enable_mongo=1; --echo # --echo # Test the MONGO table type @@ -130,7 +130,9 @@ DROP TABLE t1; --echo # --echo # try CRUD operations --echo # +--disable_query_log --exec $MONGO --eval "db.testcoll.drop()" --quiet +--enable_query_log eval CREATE TABLE t1 (_id INT(4) NOT NULL, msg CHAR(64)) ENGINE=CONNECT TABLE_TYPE=$TYPE TABNAME='testcoll' OPTION_LIST='Driver=$DRV,Version=$VERS' $CONN; @@ -147,7 +149,9 @@ DROP TABLE t1; --echo # --echo # List states whose population is equal or more than 10 millions --echo # +--disable_query_log --exec $MONGO --eval "db.cities.drop()" --quiet +--enable_query_log --exec $MONGOIMPORT --quiet $MTR_SUITE_DIR/std_data/cities.json eval CREATE TABLE t1 ( _id char(5) NOT NULL, @@ -204,4 +208,4 @@ SELECT * FROM t1; DROP TABLE t1; --exec $MONGO --eval "db.testcoll.drop()" --quiet -#set connect_enable_mongo=0; +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/t/tbl_thread.test b/storage/connect/mysql-test/connect/t/tbl_thread.test index 68a0ebcd44d156b025b0fdfbe92fe107a3864632..05409c695fb82a15005f17b1a57befb7652458aa 100644 --- a/storage/connect/mysql-test/connect/t/tbl_thread.test +++ b/storage/connect/mysql-test/connect/t/tbl_thread.test @@ -56,7 +56,7 @@ SELECT * FROM t5; eval CREATE TABLE total (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5' OPTION_LIST='thread=yes,port=$PORT'; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by a desc; set connect_xtrace=0; @@ -85,7 +85,7 @@ SELECT * FROM t2; --replace_result $PORT PORT --eval CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=$PORT'; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by v desc; set connect_xtrace=0; DROP TABLE t1,t2,total; @@ -101,7 +101,7 @@ SELECT * FROM t2; --replace_result $PORT PORT --eval CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=$PORT'; -set connect_xtrace=1; +set connect_xtrace=96; SELECT * FROM total order by v desc; set connect_xtrace=0; diff --git a/storage/connect/mysql-test/connect/t/vcol.test b/storage/connect/mysql-test/connect/t/vcol.test new file mode 100644 index 0000000000000000000000000000000000000000..88b822102d0801b9328935d7d81ea6eab48e7ef1 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/vcol.test @@ -0,0 +1,31 @@ +let datadir= `select @@datadir`; +--copy_file $MTR_SUITE_DIR/std_data/boys.txt $datadir/test/boys.txt + +create table t1 ( + #linenum int(6) not null default 0 special=rowid, + name char(12) not null, + city char(11) not null, + birth date not null date_format='DD/MM/YYYY', + hired date not null date_format='DD/MM/YYYY' flag=36, + agehired int(3) as (floor(datediff(hired,birth)/365.25)) + ) +engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1; +select * from t1; +drop table t1; + +--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN +create table t1 ( + #linenum int(6) not null default 0 special=rowid, + name char(12) not null, + city char(11) not null, + birth date not null date_format='DD/MM/YYYY', + hired date not null date_format='DD/MM/YYYY' flag=36, + agehired int(3) as (floor(datediff(hired,birth)/365.25)), + index (agehired) + ) +engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1; + +# +# Clean up +# +--remove_file $datadir/test/boys.txt diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 70a0a6a14503741d7402f607c7ff34cd6bcec7c2..f7b1a43a95da135f9b7e67a6c1d503928973457c 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -137,10 +137,10 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) case SQL_WLONGVARCHAR: // (-10) w = true; case SQL_LONGVARCHAR: // (-1) - if (GetTypeConv() == TPC_YES) { + if (GetTypeConv() == TPC_YES || GetTypeConv() == TPC_FORCE) { v = 'V'; type = TYPE_STRING; - len = MY_MIN(abs(len), GetConvSize()); + len = (len) ? MY_MIN(abs(len), GetConvSize()) : GetConvSize(); } else type = TYPE_ERROR; @@ -190,12 +190,23 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) case SQL_BIGINT: // (-5) type = TYPE_BIGINT; break; - case SQL_UNKNOWN_TYPE: // 0 case SQL_BINARY: // (-2) case SQL_VARBINARY: // (-3) case SQL_LONGVARBINARY: // (-4) - case SQL_GUID: // (-11) - default: + if (GetTypeConv() == TPC_FORCE) { + v = 'V'; + type = TYPE_STRING; + len = (len) ? MY_MIN(abs(len), GetConvSize()) : GetConvSize(); + } else + type = TYPE_ERROR; + + break; + case SQL_GUID: // (-11) + type = TYPE_STRING; + len = 36; + break; + case SQL_UNKNOWN_TYPE: // 0 + default: type = TYPE_ERROR; len = 0; } // endswitch type @@ -364,7 +375,7 @@ PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table, length[11] = 255; } // endif ocp - if (trace) + if (trace(1)) htrc("ODBCColumns: max=%d len=%d,%d,%d,%d\n", maxres, length[0], length[1], length[2], length[3]); @@ -381,7 +392,7 @@ PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table, if (info || !qrp) // Info table return qrp; - if (trace) + if (trace(1)) htrc("Getting col results ncol=%d\n", qrp->Nbcol); if (!(cap = AllocCatInfo(g, CAT_COL, db, table, qrp))) @@ -396,7 +407,7 @@ PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table, qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("Columns: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -536,7 +547,7 @@ PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info) } else maxres = 0; - if (trace) + if (trace(1)) htrc("ODBCDrivers: max=%d len=%d\n", maxres, length[0]); /************************************************************************/ @@ -593,7 +604,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info) maxres = 0; } // endif info - if (trace) + if (trace(1)) htrc("ODBCDataSources: max=%d len=%d\n", maxres, length[0]); /************************************************************************/ @@ -666,7 +677,7 @@ PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat, PCSZ tabtyp, length[4] = 255; } // endif info - if (trace) + if (trace(1)) htrc("ODBCTables: max=%d len=%d,%d\n", maxres, length[0], length[1]); /************************************************************************/ @@ -687,7 +698,7 @@ PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat, PCSZ tabtyp, cap->Pat = tabtyp; - if (trace) + if (trace(1)) htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol); /************************************************************************/ @@ -697,7 +708,7 @@ PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat, PCSZ tabtyp, qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("Tables: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -755,7 +766,7 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) n = ocp->GetMaxValue(SQL_MAX_COLUMN_NAME_LEN); length[3] = (n) ? (n + 1) : 128; - if (trace) + if (trace(1)) htrc("ODBCPrimaryKeys: max=%d len=%d,%d,%d\n", maxres, length[0], length[1], length[2]); @@ -765,7 +776,7 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) qrp = PlgAllocResult(g, ncol, maxres, IDS_PKEY, buftyp, NULL, length, false, true); - if (trace) + if (trace(1)) htrc("Getting pkey results ncol=%d\n", qrp->Nbcol); cap = AllocCatInfo(g, CAT_KEY, NULL, table, qrp); @@ -777,7 +788,7 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("PrimaryKeys: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -838,7 +849,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, n = ocp->GetMaxValue(SQL_MAX_COLUMN_NAME_LEN); length[7] = (n) ? (n + 1) : 128; - if (trace) + if (trace(1)) htrc("SemStatistics: max=%d pat=%s\n", maxres, SVP(pat)); /************************************************************************/ @@ -847,7 +858,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, qrp = PlgAllocResult(g, ncol, maxres, IDS_STAT, buftyp, NULL, length, false, true); - if (trace) + if (trace(1)) htrc("Getting stat results ncol=%d\n", qrp->Nbcol); cap = AllocCatInfo(g, CAT_STAT, NULL, pat, qrp); @@ -861,7 +872,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, qrp->Nblin = n; // ResetNullValues(cap); - if (trace) + if (trace(1)) htrc("Statistics: NBCOL=%d NBLIN=%d\n", qrp->Nbcol, qrp->Nblin); } else @@ -918,7 +929,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt) && strcmp((char*)state, "00000"); i++) { m_ErrMsg[i] = (PSZ)PlugDup(g, (char*)msg); - if (trace) + if (trace(1)) htrc("%s: %s, Native=%d\n", state, msg, native); rc = SQLError(pdb->m_henv, pdb->m_hdbc, hstmt, state, @@ -932,7 +943,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt) MSG(BAD_HANDLE_VAL)); m_ErrMsg[0] = (PSZ)PlugDup(g, (char*)msg); - if (trace) + if (trace(1)) htrc("%s: rc=%hd\n", SVP(m_ErrMsg[0]), m_RC); return true; @@ -941,7 +952,7 @@ bool DBX::BuildErrorMessage(ODBConn* pdb, HSTMT hstmt) } else m_ErrMsg[0] = "No connexion address provided"; - if (trace) + if (trace(1)) htrc("%s: rc=%hd (%s)\n", SVP(m_Msg), m_RC, SVP(m_ErrMsg[0])); return true; @@ -1004,7 +1015,7 @@ bool ODBConn::Check(RETCODE rc) { switch (rc) { case SQL_SUCCESS_WITH_INFO: - if (trace) { + if (trace(1)) { DBX x(rc); if (x.BuildErrorMessage(this, m_hstmt)) @@ -1223,7 +1234,7 @@ void ODBConn::AllocConnect(DWORD Options) if ((signed)m_LoginTimeout >= 0) { rc = SQLSetConnectOption(m_hdbc, SQL_LOGIN_TIMEOUT, m_LoginTimeout); - if (trace && rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) + if (trace(1) && rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) htrc("Warning: Failure setting login timeout\n"); } // endif Timeout @@ -1231,7 +1242,7 @@ void ODBConn::AllocConnect(DWORD Options) if (!m_Updatable) { rc = SQLSetConnectOption(m_hdbc, SQL_ACCESS_MODE, SQL_MODE_READ_ONLY); - if (trace && rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) + if (trace(1) && rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) htrc("Warning: Failure setting read only access mode\n"); } // endif @@ -1385,7 +1396,7 @@ void ODBConn::GetConnectInfo() else m_Updatable = false; - if (trace) + if (trace(1)) htrc("Warning: data source is readonly\n"); } else // Make data source is !Updatable @@ -1397,7 +1408,7 @@ void ODBConn::GetConnectInfo() rc = SQLGetInfo(m_hdbc, SQL_IDENTIFIER_QUOTE_CHAR, m_IDQuoteChar, sizeof(m_IDQuoteChar), &nResult); - if (trace) + if (trace(1)) htrc("DBMS: %s, Version: %s, rc=%d\n", GetStringInfo(SQL_DBMS_NAME), GetStringInfo(SQL_DBMS_VER), rc); @@ -1447,7 +1458,7 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols) OnSetOptions(hstmt); b = true; - if (trace) + if (trace(1)) htrc("ExecDirect hstmt=%p %.256s\n", hstmt, sql); if (m_Tdb->Srcdef) { @@ -1510,7 +1521,7 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols) ThrowDBX(m_G->Message); } // endif tp - if (trace) + if (trace(1)) htrc("Binding col=%u type=%d buf=%p len=%d slen=%p\n", n, tp, buffer, len, colp->GetStrLen()); @@ -1523,7 +1534,7 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols) } // endif pcol } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -1569,7 +1580,7 @@ int ODBConn::GetResultSize(char *sql, ODBCCOL *colp) } catch(DBX *x) { strcpy(m_G->Message, x->GetErrorMessage(0)); - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -1610,7 +1621,7 @@ int ODBConn::Fetch(int pos) } // endif m_RowsetSize // } while (rc == SQL_STILL_EXECUTING); - if (trace > 1) + if (trace(2)) htrc("Fetch: hstmt=%p RowseSize=%d rc=%d\n", m_hstmt, m_RowsetSize, rc); @@ -1626,7 +1637,7 @@ int ODBConn::Fetch(int pos) m_Fetch++; m_Rows += irc; } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -1662,7 +1673,7 @@ int ODBConn::PrepareSQL(char *sql) m_Transact = true; } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -1693,7 +1704,7 @@ int ODBConn::PrepareSQL(char *sql) OnSetOptions(hstmt); b = true; - if (trace) + if (trace(1)) htrc("Prepare hstmt=%p %.64s\n", hstmt, sql); do { @@ -1708,7 +1719,7 @@ int ODBConn::PrepareSQL(char *sql) } while (rc == SQL_STILL_EXECUTING); } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -1881,7 +1892,7 @@ bool ODBConn::ExecSQLcommand(char *sql) OnSetOptions(hstmt); b = true; - if (trace) + if (trace(1)) htrc("ExecSQLcommand hstmt=%p %.64s\n", hstmt, sql); // Proceed with command execution @@ -1908,7 +1919,7 @@ bool ODBConn::ExecSQLcommand(char *sql) } // endif ncol } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -2250,10 +2261,10 @@ class SQLQualifiedName return (SQLCHAR *) (m_part[i].length ? m_part[i].str : NULL); } // end of ptr - size_t length(uint i) + SQLSMALLINT length(uint i) { DBUG_ASSERT(i < max_parts); - return m_part[i].length; + return (SQLSMALLINT)m_part[i].length; } // end of length }; // end of class SQLQualifiedName @@ -2394,7 +2405,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) if ((rc = SQLFetch(hstmt)) == SQL_NO_DATA_FOUND) break; else if (rc != SQL_SUCCESS) { - if (trace > 1 || (trace && rc != SQL_SUCCESS_WITH_INFO)) { + if (trace(2) || (trace(1) && rc != SQL_SUCCESS_WITH_INFO)) { UCHAR msg[SQL_MAX_MESSAGE_LENGTH + 1]; UCHAR state[SQL_SQLSTATE_SIZE + 1]; RETCODE erc; @@ -2427,7 +2438,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) else if (vlen[n] == SQL_NULL_DATA) pval[n]->SetNull(true); else if (crp->Type == TYPE_STRING/* && vlen[n] != SQL_NULL_DATA*/) - pval[n]->SetValue_char(pbuf[n], vlen[n]); + pval[n]->SetValue_char(pbuf[n], (int)vlen[n]); else pval[n]->SetNull(false); @@ -2466,7 +2477,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) irc = (int)crow; } catch(DBX *x) { - if (trace) + if (trace(1)) for (int i = 0; i < MAX_NUM_OF_MSG && x->m_ErrMsg[i]; i++) htrc(x->m_ErrMsg[i]); @@ -2605,12 +2616,12 @@ void ODBConn::Close() rc = SQLDisconnect(m_hdbc); - if (trace && rc != SQL_SUCCESS) + if (trace(1) && rc != SQL_SUCCESS) htrc("Error: SQLDisconnect rc=%d\n", rc); rc = SQLFreeConnect(m_hdbc); - if (trace && rc != SQL_SUCCESS) + if (trace(1) && rc != SQL_SUCCESS) htrc("Error: SQLFreeConnect rc=%d\n", rc); m_hdbc = SQL_NULL_HDBC; @@ -2619,7 +2630,7 @@ void ODBConn::Close() if (m_henv != SQL_NULL_HENV) { rc = SQLFreeEnv(m_henv); - if (trace && rc != SQL_SUCCESS) // Nothing we can do + if (trace(1) && rc != SQL_SUCCESS) // Nothing we can do htrc("Error: SQLFreeEnv failure ignored in Close\n"); m_henv = SQL_NULL_HENV; diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h index 6a0a8be8ff84dad07d474381e9c6f49238236297..5446e0d2a0772d4c2da48994e07c76f398940355 100644 --- a/storage/connect/plgdbsem.h +++ b/storage/connect/plgdbsem.h @@ -362,7 +362,8 @@ enum COLUSE {U_P = 0x01, /* the projection list. */ U_IS_NULL = 0x80, /* The column has a null value */ U_SPECIAL = 0x100, /* The column is special */ U_UNSIGNED = 0x200, /* The column type is unsigned */ - U_ZEROFILL = 0x400}; /* The column is zero filled */ + U_ZEROFILL = 0x400, /* The column is zero filled */ + U_UUID = 0x800}; /* The column is a UUID */ /***********************************************************************/ /* DB description class and block pointer definitions. */ diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index f669d64463733b51bf98dd2b7d2f675412063eae..e296553d8e241f19c45418f871437ead94bc4d82 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -1,11 +1,11 @@ /********** PlgDBUtl Fpe C++ Program Source Code File (.CPP) ***********/ /* PROGRAM NAME: PLGDBUTL */ /* ------------- */ -/* Version 4.0 */ +/* Version 4.1 */ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2018 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -215,35 +215,13 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode) } DllExport void SetTrc(void) - { +{ // If tracing is on, debug must be initialized. debug = pfile; - } // end of SetTrc - -#if 0 -/**************************************************************************/ -/* Tracing output function. */ -/**************************************************************************/ -void ptrc(char const *fmt, ...) - { - va_list ap; - va_start (ap, fmt); - -// if (trace == 0 || (trace == 1 && !pfile) || !fmt) -// printf("In %s wrong trace=%d pfile=%p fmt=%p\n", -// __FILE__, trace, pfile, fmt); - - if (trace == 1) - vfprintf(pfile, fmt, ap); - else - vprintf(fmt, ap); - - va_end (ap); - } // end of ptrc -#endif // 0 +} // end of SetTrc /**************************************************************************/ -/* Allocate the result structure that will contain result data. */ +/* SubAllocate the result structure that will contain result data. */ /**************************************************************************/ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, int *buftyp, XFLD *fldtyp, @@ -307,7 +285,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, else crp->Kdata = NULL; - if (trace) + if (trace(1)) htrc("Column(%d) %s type=%d len=%d value=%p\n", crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata); @@ -475,7 +453,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci) char *tp, *sp; bool b; - if (trace) + if (trace(2)) htrc("LIKE: strg='%s' pattern='%s'\n", strg, pat); if (ci) { /* Case insensitive test */ @@ -541,10 +519,10 @@ bool EvalLikePattern(LPCSTR sp, LPCSTR tp) { LPSTR p; char c; - int n; + ssize_t n; bool b, t = false; - if (trace) + if (trace(2)) htrc("Eval Like: sp=%s tp=%s\n", (sp) ? sp : "Null", (tp) ? tp : "Null"); @@ -582,7 +560,7 @@ bool EvalLikePattern(LPCSTR sp, LPCSTR tp) else n = strlen(tp); /* Get length of pattern head */ - if (trace) + if (trace(2)) htrc(" testing: t=%d sp=%s tp=%s p=%p\n", t, sp, tp, p); if (n > (signed)strlen(sp)) /* If head is longer than strg */ @@ -628,7 +606,7 @@ bool EvalLikePattern(LPCSTR sp, LPCSTR tp) b = !strcmp(sp, tp); } /* endif p */ - if (trace) + if (trace(2)) htrc(" done: b=%d n=%d sp=%s tp=%s\n", b, n, (sp) ? sp : "Null", tp); @@ -668,7 +646,7 @@ char *MakeEscape(PGLOBAL g, char* str, char q) /***********************************************************************/ void PlugConvertConstant(PGLOBAL g, void* & value, short& type) { - if (trace) + if (trace(1)) htrc("PlugConvertConstant: value=%p type=%hd\n", value, type); if (type != TYPE_XOBJECT) { @@ -688,7 +666,7 @@ PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag) int rc; PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR)); - if (trace) + if (trace(1)) htrc("MakeDateFormat: dfmt=%s\n", dfmt); memset(pdp, 0, sizeof(DATPAR)); @@ -711,7 +689,7 @@ PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag) rc = fmdflex(pdp); pthread_mutex_unlock(&parmut); - if (trace) + if (trace(1)) htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc); return pdp; @@ -733,7 +711,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6]) else // assume standard MySQL date format fmt = "%4d-%2d-%2d %2d:%2d:%2d"; - if (trace > 1) + if (trace(2)) htrc("ExtractDate: dts=%s fmt=%s defy=%d\n", dts, fmt, defy); // Set default values for time only use @@ -816,7 +794,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6]) } // endfor i - if (trace > 1) + if (trace(2)) htrc("numval=%d val=(%d,%d,%d,%d,%d,%d)\n", numval, val[0], val[1], val[2], val[3], val[4], val[5]); @@ -833,18 +811,18 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype) PFBLOCK fp; PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr; - if (trace) { + if (trace(1)) { htrc("PlugOpenFile: fname=%s ftype=%s\n", fname, ftype); htrc("dbuserp=%p\n", dbuserp); } // endif trace if ((fop= global_fopen(g, MSGID_OPEN_MODE_STRERROR, fname, ftype)) != NULL) { - if (trace) + if (trace(1)) htrc(" fop=%p\n", fop); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); - if (trace) + if (trace(1)) htrc(" fp=%p\n", fp); // fname may be in volatile memory such as stack @@ -857,7 +835,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype) dbuserp->Openlist = fp; } /* endif fop */ - if (trace) + if (trace(1)) htrc(" returning fop=%p\n", fop); return (fop); @@ -888,7 +866,7 @@ int PlugCloseFile(PGLOBAL g, PFBLOCK fp, bool all) { int rc = 0; - if (trace) + if (trace(1)) htrc("PlugCloseFile: fp=%p count=%hd type=%hd\n", fp, ((fp) ? fp->Count : 0), ((fp) ? fp->Type : 0)); @@ -1050,7 +1028,7 @@ int GetIniSize(char *section, char *key, char *def, char *ini) n *= 1024; } // endswitch c - if (trace) + if (trace(1)) htrc("GetIniSize: key=%s buff=%s i=%d n=%d\n", key, buff, i, n); return n; @@ -1086,7 +1064,7 @@ DllExport PSZ GetIniString(PGLOBAL g, void *mp, LPCSTR sec, LPCSTR key, p = (PSZ)PlugSubAlloc(g, mp, n + 1); - if (trace) + if (trace(1)) htrc("GetIniString: sec=%s key=%s buf=%s\n", sec, key, buf); strcpy(p, buf); @@ -1237,7 +1215,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e) /* so it can be freed at the normal or error query completion. */ /***********************************************************************/ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp) - { +{ //bool b; size_t maxsub, minsub; void *arp = (area) ? area : g->Sarea; @@ -1253,7 +1231,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp) // done to check whether the block is already there. // b = mp.Sub; mp.Sub = false; // Restrict suballocation to one quarter - } // endif Memp + } // endif Memp // Suballoc when possible if mp.Sub is initially true, but leaving // a minimum amount of storage for future operations such as the @@ -1263,35 +1241,40 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp) maxsub = (pph->FreeBlk < minsub) ? 0 : pph->FreeBlk - minsub; mp.Sub = mp.Size <= ((mp.Sub) ? maxsub : (maxsub >> 2)); - if (trace > 1) - htrc("PlgDBalloc: in %p size=%d used=%d free=%d sub=%d\n", - arp, mp.Size, pph->To_Free, pph->FreeBlk, mp.Sub); + if (trace(2)) + htrc("PlgDBalloc: in %p size=%d used=%d free=%d sub=%d\n", + arp, mp.Size, pph->To_Free, pph->FreeBlk, mp.Sub); - if (!mp.Sub) { + if (!mp.Sub) { // For allocations greater than one fourth of remaining storage // in the area, do allocate from virtual storage. + const char*v = "malloc"; #if defined(__WIN__) - if (mp.Size >= BIGMEM) - mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); - else + if (mp.Size >= BIGMEM) { + v = "VirtualAlloc"; + mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + } else #endif mp.Memp = malloc(mp.Size); - if (!mp.Inlist && mp.Memp) { + if (trace(8)) + htrc("PlgDBalloc: %s(%d) at %p\n", v, mp.Size, mp.Memp); + + if (!mp.Inlist && mp.Memp) { // New allocated block, put it in the memory block chain. PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr; mp.Next = dbuserp->Memlist; dbuserp->Memlist = ∓ mp.Inlist = true; - } // endif mp + } // endif mp } else // Suballocating is Ok. mp.Memp = PlugSubAlloc(g, area, mp.Size); return mp.Memp; - } // end of PlgDBalloc +} // end of PlgDBalloc /***********************************************************************/ /* PlgDBrealloc: reallocates memory conditionally. */ @@ -1306,7 +1289,7 @@ void *PlgDBrealloc(PGLOBAL g, void *area, MBLOCK& mp, size_t newsize) // assert (mp.Memp != NULL); #endif - if (trace > 1) + if (trace(2)) htrc("PlgDBrealloc: %p size=%d sub=%d\n", mp.Memp, mp.Size, mp.Sub); if (newsize == mp.Size) @@ -1326,10 +1309,14 @@ void *PlgDBrealloc(PGLOBAL g, void *area, MBLOCK& mp, size_t newsize) mp.Memp = PlugSubAlloc(g, area, newsize); memcpy(mp.Memp, m.Memp, MY_MIN(m.Size, newsize)); PlgDBfree(m); // Free the old block - } else if (!(mp.Memp = realloc(mp.Memp, newsize))) { - mp = m; // Possible only if newsize > Size - return NULL; // Failed - } // endif's + } else { + if (!(mp.Memp = realloc(mp.Memp, newsize))) { + mp = m; // Possible only if newsize > Size + return NULL; // Failed + } else if (trace(8)) + htrc("PlgDBrealloc: realloc(%ld) at %p\n", newsize, mp.Memp); + + } // endif's mp.Size = newsize; } else if (!mp.Sub || newsize > mp.Size) { @@ -1352,7 +1339,7 @@ void *PlgDBrealloc(PGLOBAL g, void *area, MBLOCK& mp, size_t newsize) } // endif's - if (trace) + if (trace(8)) htrc(" newsize=%d newp=%p sub=%d\n", mp.Size, mp.Memp, mp.Sub); return mp.Memp; @@ -1363,16 +1350,20 @@ void *PlgDBrealloc(PGLOBAL g, void *area, MBLOCK& mp, size_t newsize) /***********************************************************************/ void PlgDBfree(MBLOCK& mp) { - if (trace > 1) - htrc("PlgDBfree: %p sub=%d size=%d\n", mp.Memp, mp.Sub, mp.Size); - - if (!mp.Sub && mp.Memp) + if (!mp.Sub && mp.Memp) { + const char*v = "free"; #if defined(__WIN__) - if (mp.Size >= BIGMEM) - VirtualFree(mp.Memp, 0, MEM_RELEASE); - else + if (mp.Size >= BIGMEM) { + v = "VirtualFree"; + VirtualFree(mp.Memp, 0, MEM_RELEASE); + } else #endif - free(mp.Memp); + free(mp.Memp); + + if (trace(8)) + htrc("PlgDBfree: %s(%p) size=%d\n", v, mp.Memp, mp.Size); + + } // endif mp // Do not reset Next to avoid cutting the Mblock chain mp.Memp = NULL; @@ -1384,7 +1375,7 @@ void PlgDBfree(MBLOCK& mp) /* Program for sub-allocating one item in a storage area. */ /* Note: This function is equivalent to PlugSubAlloc except that in */ /* case of insufficient memory, it returns NULL instead of doing a */ -/* long jump. The caller must test the return value for error. */ +/* throw. The caller must test the return value for error. */ /***********************************************************************/ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) { @@ -1400,7 +1391,7 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; - if (trace > 1) + if (trace(16)) htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n", memp, size, pph->To_Free, pph->FreeBlk); @@ -1409,7 +1400,7 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) "Not enough memory in Work area for request of %d (used=%d free=%d)", (int) size, pph->To_Free, pph->FreeBlk); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return NULL; @@ -1422,7 +1413,7 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) pph->To_Free += size; // New offset of pool free block pph->FreeBlk -= size; // New size of pool free block - if (trace > 1) + if (trace(16)) htrc("Done memp=%p used=%d free=%d\n", memp, pph->To_Free, pph->FreeBlk); @@ -1453,7 +1444,7 @@ void PlugPutOut(PGLOBAL g, FILE *f, short t, void *v, uint n) { char m[64]; - if (trace) + if (trace(1)) htrc("PUTOUT: f=%p t=%d v=%p n=%d\n", f, t, v, n); if (!v) diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp index 7b408870238715648f44619f05936606da138c73..887527e38ab802fc61a4c7684f397ba325e2c34e 100644 --- a/storage/connect/plugutil.cpp +++ b/storage/connect/plugutil.cpp @@ -136,7 +136,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) { PGLOBAL g; - if (trace > 1) + if (trace(2)) htrc("PlugInit: Language='%s'\n", ((!Language) ? "Null" : (char*)Language)); @@ -205,7 +205,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) _splitpath(FileName, drive, direc, fname, ftype); - if (trace > 1) { + if (trace(2)) { htrc("after _splitpath: FileName=%s\n", FileName); htrc("drive=%s dir=%s fname=%s ext=%s\n", SVP(drive), direc, fname, ftype); @@ -213,7 +213,7 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) _makepath(pBuff, drive, direc, fname, ""); - if (trace > 1) + if (trace(2)) htrc("buff='%s'\n", pBuff); return pBuff; @@ -246,7 +246,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) char *drive = NULL, *defdrv = NULL; #endif - if (trace > 1) + if (trace(2)) htrc("prefix=%s fn=%s path=%s\n", prefix, FileName, defpath); if (!strncmp(FileName, "//", 2) || !strncmp(FileName, "\\\\", 2)) { @@ -263,7 +263,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) #if !defined(__WIN__) if (*FileName == '~') { if (_fullpath(pBuff, FileName, _MAX_PATH)) { - if (trace > 1) + if (trace(2)) htrc("pbuff='%s'\n", pBuff); return pBuff; @@ -298,7 +298,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) _splitpath(tmpdir, defdrv, defdir, NULL, NULL); - if (trace > 1) { + if (trace(2)) { htrc("after _splitpath: FileName=%s\n", FileName); #if defined(__WIN__) htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype); @@ -325,11 +325,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) _makepath(newname, drive, direc, fname, ftype); - if (trace > 1) + if (trace(2)) htrc("newname='%s'\n", newname); if (_fullpath(pBuff, newname, _MAX_PATH)) { - if (trace > 1) + if (trace(2)) htrc("pbuff='%s'\n", pBuff); return pBuff; @@ -470,7 +470,7 @@ bool AllocSarea(PGLOBAL g, uint size) #if defined(DEVELOPMENT) if (true) { #else - if (trace) { + if (trace(8)) { #endif if (g->Sarea) htrc("Work area of %u allocated at %p\n", size, g->Sarea); @@ -498,7 +498,7 @@ void FreeSarea(PGLOBAL g) #if defined(DEVELOPMENT) if (true) #else - if (trace) + if (trace(8)) #endif htrc("Freeing Sarea at %p size = %d\n", g->Sarea, g->Sarea_Size); @@ -545,7 +545,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; - if (trace > 3) + if (trace(16)) htrc("SubAlloc in %p size=%d used=%d free=%d\n", memp, size, pph->To_Free, pph->FreeBlk); @@ -556,10 +556,10 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) "Not enough memory in %s area for request of %u (used=%d free=%d)", pname, (uint)size, pph->To_Free, pph->FreeBlk); - if (trace) + if (trace(1)) htrc("PlugSubAlloc: %s\n", g->Message); - throw 1234; + throw 1234; } /* endif size OS32 code */ /*********************************************************************/ @@ -569,7 +569,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) pph->To_Free += (OFFSET)size; /* New offset of pool free block */ pph->FreeBlk -= (uint)size; /* New size of pool free block */ - if (trace > 3) + if (trace(16)) htrc("Done memp=%p used=%d free=%d\n", memp, pph->To_Free, pph->FreeBlk); diff --git a/storage/connect/preparse.h b/storage/connect/preparse.h index f16624548fb7491372930fdf75e442a73905e85a..3db7a2af1cd7088ded2adc397359450d71864797 100644 --- a/storage/connect/preparse.h +++ b/storage/connect/preparse.h @@ -8,7 +8,7 @@ /***********************************************************************/ typedef struct _datpar { const char *Format; // Points to format to decode - char *Curp; // Points to current parsing position + const char *Curp; // Points to current parsing position char *InFmt; // Start of input format char *OutFmt; // Start of output format int Index[8]; // Indexes of date values diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 0fb24baa7856ee7ae5fc57a01b3b33a4a4bc7e9f..e4f169575f8c122e5e9f67eb1dff82003242fa89 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -450,7 +450,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) } // endswitch tc // lrecl must be at least recln to avoid buffer overflow - if (trace) + if (trace(1)) htrc("Lrecl: Calculated=%d defined=%d\n", recln, Hc->GetIntegerOption("Lrecl")); diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp index 5065d86ce6a7ba0abe9f86fe4124c97fe14620fe..93de0598fe8163e2878081262331732732d5f3b0 100644 --- a/storage/connect/tabcol.cpp +++ b/storage/connect/tabcol.cpp @@ -33,7 +33,7 @@ XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name) Schema = NULL; Qualifier = NULL; - if (trace) + if (trace(1)) htrc("XTAB: making new TABLE %s %s\n", Name, Srcdef); } // end of XTAB constructor @@ -49,7 +49,7 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name) Schema = tp->Schema; Qualifier = tp->Qualifier; - if (trace) + if (trace(1)) htrc(" making copy TABLE %s %s\n", Name, SVP(Srcdef)); } // end of XTAB constructor @@ -61,7 +61,7 @@ PTABLE XTAB::Link(PTABLE tab2) { PTABLE tabp; - if (trace) + if (trace(1)) htrc("Linking tables %s... to %s\n", Name, tab2->Name); for (tabp = this; tabp->Next; tabp = tabp->Next) ; @@ -117,7 +117,7 @@ COLUMN::COLUMN(LPCSTR name) : Name(name) To_Col = NULL; Qualifier = NULL; - if (trace) + if (trace(1)) htrc(" making new COLUMN %s\n", Name); } // end of COLUMN constructor diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 5b9667a6c840fe77353cf4a1026805d8a15e1a39..29cbbb35765b71f0040f6bb2411c3d9d57d527fd 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -704,7 +704,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) // savmin = cdp->GetBmap(); // cdp->SetBmap(PlugSubAlloc(g, NULL, block * sizeof(int))); - if (trace) + if (trace(1)) htrc("Dval(%p) Bmap(%p) col(%d) %s Block=%d lg=%d\n", cdp->GetDval(), cdp->GetBmap(), i, cdp->GetName(), block, lg); @@ -729,7 +729,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) memset(cdp->GetMax(), 0, block * lg); } // endif Type - if (trace) + if (trace(1)) htrc("min(%p) max(%p) col(%d) %s Block=%d lg=%d\n", cdp->GetMin(), cdp->GetMax(), i, cdp->GetName(), block, lg); @@ -901,7 +901,7 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g) "wb", (int)errno, filename); strcat(strcat(g->Message, ": "), strerror(errno)); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); return true; @@ -1634,7 +1634,7 @@ int TDBDOS::TestBlock(PGLOBAL g) To_Filter = NULL; // So remove filter } // endswitch Beval - if (trace) + if (trace(1)) htrc("BF Eval Beval=%d\n", Beval); } // endif To_BlkFil @@ -1647,8 +1647,8 @@ int TDBDOS::TestBlock(PGLOBAL g) /***********************************************************************/ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) { - int k, n, rc = RC_OK; - bool fixed, doit, sep, b = (pxdf != NULL); + int k, n, rc = RC_OK; + bool fixed, doit, sep, b = (pxdf != NULL); PCOL *keycols, colp; PIXDEF xdp, sxp = NULL; PKPDEF kdp; @@ -1694,8 +1694,8 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) try { // Allocate all columns that will be used by indexes. - // This must be done before opening the table so specific - // column initialization can be done (in particular by TDBVCT) + // This must be done before opening the table so specific + // column initialization can be done (in particular by TDBVCT) for (n = 0, xdp = pxdf; xdp; xdp = xdp->GetNext()) for (kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) { if (!(colp = ColDB(g, kdp->GetName(), 0))) { @@ -1779,7 +1779,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) return RC_INFO; // Error or Physical table does not exist } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); rc = RC_FX; } catch (const char *msg) { @@ -1902,7 +1902,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted) } // endif brc } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); brc = true; } catch (const char *msg) { @@ -2001,7 +2001,7 @@ int TDBDOS::Cardinality(PGLOBAL g) if (len >= 0) { int rec; - if (trace) + if (trace(1)) htrc("Estimating lines len=%d ending=%d/n", len, ((PDOSDEF)To_Def)->Ending); @@ -2018,7 +2018,7 @@ int TDBDOS::Cardinality(PGLOBAL g) Cardinal = (len + rec - 1) / rec; - if (trace) + if (trace(1)) htrc("avglen=%d MaxSize%d\n", rec, Cardinal); } // endif len @@ -2048,7 +2048,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) if (len >= 0) { int rec; - if (trace) + if (trace(1)) htrc("Estimating lines len=%d ending=%d/n", len, ((PDOSDEF)To_Def)->Ending); @@ -2059,7 +2059,7 @@ int TDBDOS::GetMaxSize(PGLOBAL g) rec = EstimatedLength() + ((PDOSDEF)To_Def)->Ending; MaxSize = (len + rec - 1) / rec; - if (trace) + if (trace(1)) htrc("avglen=%d MaxSize%d\n", rec, MaxSize); } // endif len @@ -2108,7 +2108,7 @@ bool TDBDOS::IsUsingTemp(PGLOBAL) /***********************************************************************/ bool TDBDOS::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("DOS OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", this, Tdb_No, Use, Mode); @@ -2184,7 +2184,7 @@ bool TDBDOS::OpenDB(PGLOBAL g) } else memset(To_Line, 0, linelen); - if (trace) + if (trace(1)) htrc("OpenDos: R%hd mode=%d To_Line=%p\n", Tdb_No, Mode, To_Line); if (SkipHeader(g)) // When called from CSV/FMT files @@ -2202,7 +2202,7 @@ bool TDBDOS::OpenDB(PGLOBAL g) /***********************************************************************/ int TDBDOS::ReadDB(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("DOS ReadDB: R%d Mode=%d key=%p link=%p Kindex=%p To_Line=%p\n", GetTdb_No(), Mode, To_Key_Col, To_Link, To_Kindex, To_Line); @@ -2227,7 +2227,7 @@ int TDBDOS::ReadDB(PGLOBAL g) if (SetRecpos(g, recpos)) return RC_FX; - if (trace > 1) + if (trace(2)) htrc("File position is now %d\n", GetRecpos()); if (Mode == MODE_READ) @@ -2243,7 +2243,7 @@ int TDBDOS::ReadDB(PGLOBAL g) } // endif To_Kindex - if (trace > 1) + if (trace(2)) htrc(" ReadDB: this=%p To_Line=%p\n", this, To_Line); /*********************************************************************/ @@ -2279,14 +2279,14 @@ bool TDBDOS::PrepareWriting(PGLOBAL) /***********************************************************************/ int TDBDOS::WriteDB(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("DOS WriteDB: R%d Mode=%d \n", Tdb_No, Mode); // Make the line to write if (PrepareWriting(g)) return RC_FX; - if (trace > 1) + if (trace(2)) htrc("Write: line is='%s'\n", To_Line); // Now start the writing process @@ -2403,7 +2403,7 @@ DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am) Dcm = (*p) ? atoi(p) : GetScale(); } // endif fmt - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); } // end of DOSCOL constructor @@ -2518,7 +2518,7 @@ void DOSCOL::ReadColumn(PGLOBAL g) double dval; PTDBDOS tdbp = (PTDBDOS)To_Tdb; - if (trace > 1) + if (trace(2)) htrc( "DOS ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type); @@ -2607,13 +2607,13 @@ void DOSCOL::WriteColumn(PGLOBAL g) int i, k, len, field; PTDBDOS tdbp = (PTDBDOS)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("DOS WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, tdbp->GetTdb_No(), ColUse, Status); p = tdbp->To_Line + Deplac; - if (trace > 1) + if (trace(2)) htrc("Lrecl=%d deplac=%d int=%d\n", tdbp->Lrecl, Deplac, Long); field = Long; @@ -2630,7 +2630,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) } // endif Ftype - if (trace > 1) + if (trace(2)) htrc("Long=%d field=%d coltype=%d colval=%p\n", Long, field, Buf_Type, Value); @@ -2703,7 +2703,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) } else // Standard CONNECT format p2 = Value->ShowValue(Buf, field); - if (trace) + if (trace(1)) htrc("new length(%p)=%d\n", p2, strlen(p2)); if ((len = strlen(p2)) > field) { @@ -2714,7 +2714,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) if (p2[i] == '.') p2[i] = Dsp; - if (trace > 1) + if (trace(2)) htrc("buffer=%s\n", p2); /*******************************************************************/ @@ -2724,7 +2724,7 @@ void DOSCOL::WriteColumn(PGLOBAL g) memset(p, ' ', field); memcpy(p, p2, len); - if (trace > 1) + if (trace(2)) htrc(" col write: '%.*s'\n", len, p); } // endif Use @@ -2881,4 +2881,3 @@ bool DOSCOL::AddDistinctValue(PGLOBAL g) } // end of AddDistinctValue /* ------------------------------------------------------------------- */ - diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h index 948b357dc1fedb29bb187c14f7639ba4ade4a3c4..bdde37adaad40dca873f3ab3dc73ad928aaab292 100644 --- a/storage/connect/tabdos.h +++ b/storage/connect/tabdos.h @@ -29,6 +29,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ friend class TXTFAM; friend class DBFBASE; friend class UNZIPUTL; + friend class JSONCOL; public: // Constructor DOSDEF(void); diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp index a75b373b5640abd851da0834c53c27d2c5f337f1..64d401bef15152aeda4dafba9a9ae35ad8677cd3 100644 --- a/storage/connect/tabext.cpp +++ b/storage/connect/tabext.cpp @@ -433,7 +433,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) } else Query->Resize(len); - if (trace) + if (trace(33)) htrc("Query=%s\n", Query->GetStr()); return false; @@ -527,7 +527,7 @@ bool TDBEXT::MakeCommand(PGLOBAL g) return true; } // endif p - if (trace) + if (trace(33)) htrc("Command=%s\n", stmt); Query = new(g)STRING(g, 0, stmt); @@ -585,7 +585,7 @@ EXTCOL::EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) tdbp->SetColumns(this); } // endif cprec - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); // Set additional remote access method information for column. diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp index a78d5861e53e711b76bc80c03f49b8cdcbeb76a7..1969fd4465fdaef8fe6731099d6b630c1c18f37f 100644 --- a/storage/connect/tabfix.cpp +++ b/storage/connect/tabfix.cpp @@ -291,7 +291,7 @@ bool TDBFIX::IsUsingTemp(PGLOBAL) /***********************************************************************/ bool TDBFIX::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("FIX OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d Ftype=%d\n", this, Tdb_No, Use, To_Key_Col, Mode, Ftype); @@ -345,7 +345,7 @@ bool TDBFIX::OpenDB(PGLOBAL g) /*********************************************************************/ To_BlkFil = InitBlockFilter(g, To_Filter); - if (trace) + if (trace(1)) htrc("OpenFix: R%hd mode=%d BlkFil=%p\n", Tdb_No, Mode, To_BlkFil); /*********************************************************************/ @@ -474,7 +474,7 @@ void BINCOL::ReadColumn(PGLOBAL g) int rc; PTDBFIX tdbp = (PTDBFIX)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("BIN ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type); @@ -565,7 +565,7 @@ void BINCOL::WriteColumn(PGLOBAL g) longlong n; PTDBFIX tdbp = (PTDBFIX)To_Tdb; - if (trace) { + if (trace(1)) { htrc("BIN WriteColumn: col %s R%d coluse=%.4X status=%.4X", Name, tdbp->GetTdb_No(), ColUse, Status); htrc(" Lrecl=%d\n", tdbp->Lrecl); diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 516601a5eb48f48476efef9e81774515302bce74..63fa2a636688be2be20bb358efc2496bb4dfa89f 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -185,7 +185,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) mxr = MY_MAX(0, tdp->Maxerr); - if (trace) + if (trace(1)) htrc("File %s Sep=%c Qot=%c Header=%d maxerr=%d\n", SVP(tdp->Fn), tdp->Sep, tdp->Qot, tdp->Header, tdp->Maxerr); @@ -379,7 +379,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) skip: ; // Skip erroneous line } // endfor num_read - if (trace) { + if (trace(1)) { htrc("imax=%d Lengths:", imax); for (i = 0; i < imax; i++) @@ -391,7 +391,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) tdbp->CloseDB(g); skipit: - if (trace) + if (trace(1)) htrc("CSVColumns: imax=%d hmax=%d len=%d\n", imax, hmax, length[0]); @@ -701,7 +701,7 @@ int TDBCSV::EstimatedLength(void) int n = 0; PCOLDEF cdp; - if (trace) + if (trace(1)) htrc("EstimatedLength: Fields=%d Columns=%p\n", Fields, Columns); for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) @@ -906,7 +906,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g) int i, n, len, rc = Txfp->ReadBuffer(g); bool bad = false; - if (trace > 1) + if (trace(2)) htrc("CSV: Row is '%s' rc=%d\n", To_Line, rc); if (rc != RC_OK || !Fields) @@ -934,7 +934,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g) if (p) { //len = p++ - p2; - len = p - p2 - 1;; + len = (int)(p - p2 - 1); // if (Sep != ' ') // for (; *p == ' '; p++) ; // Skip blanks @@ -978,7 +978,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g) return RC_NF; } else if ((p = strchr(p2, Sep))) - len = p - p2; + len = (int)(p - p2); else if (i == Fields - 1) len = strlen(p2); else if (Accept && Maxerr == 0) { @@ -996,7 +996,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g) } else len = 0; - Offset[i] = p2 - To_Line; + Offset[i] = (int)(p2 - To_Line); if (Mode != MODE_UPDATE) Fldlen[i] = len; @@ -1024,7 +1024,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g) char sep[2], qot[2]; int i, nlen, oldlen = strlen(To_Line); - if (trace > 1) + if (trace(2)) htrc("CSV WriteDB: R%d Mode=%d key=%p link=%p\n", Tdb_No, Mode, To_Key_Col, To_Link); @@ -1090,7 +1090,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g) To_Line[nlen] = '\0'; } // endif - if (trace > 1) + if (trace(2)) htrc("Write: line is=%s", To_Line); return false; @@ -1118,7 +1118,7 @@ int TDBCSV::CheckWrite(PGLOBAL g) { int maxlen, n, nlen = (Fields - 1); - if (trace > 1) + if (trace(2)) htrc("CheckWrite: R%d Mode=%d\n", Tdb_No, Mode); // Before writing the line we must check its length @@ -1290,7 +1290,7 @@ int TDBFMT::ReadBuffer(PGLOBAL g) else ++Linenum; - if (trace > 1) + if (trace(2)) htrc("FMT: Row %d is '%s' rc=%d\n", Linenum, To_Line, rc); // Find the offsets and lengths of the columns for this row @@ -1445,7 +1445,7 @@ void CSVCOL::ReadColumn(PGLOBAL g) Deplac = tdbp->Offset[Fldnum]; // Field offset Long = tdbp->Fldlen[Fldnum]; // Field length - if (trace > 1) + if (trace(2)) htrc("CSV ReadColumn %s Fldnum=%d offset=%d fldlen=%d\n", Name, Fldnum, Deplac, Long); @@ -1489,13 +1489,13 @@ void CSVCOL::WriteColumn(PGLOBAL g) int flen; PTDBCSV tdbp = (PTDBCSV)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("CSV WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, tdbp->GetTdb_No(), ColUse, Status); flen = GetLength(); - if (trace > 1) + if (trace(2)) htrc("Lrecl=%d Long=%d field=%d coltype=%d colval=%p\n", tdbp->Lrecl, Long, flen, Buf_Type, Value); @@ -1510,7 +1510,7 @@ void CSVCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ p = Value->ShowValue(buf); - if (trace > 1) + if (trace(2)) htrc("new length(%p)=%d\n", p, strlen(p)); if ((signed)strlen(p) > flen) { @@ -1522,7 +1522,7 @@ void CSVCOL::WriteColumn(PGLOBAL g) if (p[i] == '.') p[i] = Dsp; - if (trace > 1) + if (trace(2)) htrc("buffer=%s\n", p); /*********************************************************************/ @@ -1536,7 +1536,7 @@ void CSVCOL::WriteColumn(PGLOBAL g) } else strncpy(tdbp->Field[Fldnum], p, flen); - if (trace > 1) + if (trace(2)) htrc(" col written: '%s'\n", p); } // end of WriteColumn diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp index b6a1487955b03a846a5cf8627ccdfdf5b66206b0..275b5edaeaed7e83dc2e276b2d0946b81806d6f0 100644 --- a/storage/connect/tabjdbc.cpp +++ b/storage/connect/tabjdbc.cpp @@ -153,7 +153,7 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b) // Tabname = GetStringCatInfo(g, "Tabname", Tabname); } // endif - if (trace) + if (trace(1)) htrc("server: %s Tabname: %s", url, Tabname); // Now make the required URL @@ -470,7 +470,7 @@ bool TDBJDBC::MakeInsert(PGLOBAL g) else Prepared = true; - if (trace) + if (trace(33)) htrc("Insert=%s\n", Query->GetStr()); return false; @@ -553,7 +553,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g) { bool rc = true; - if (trace) + if (trace(1)) htrc("JDBC OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", this, Tdb_No, Use, Mode); @@ -572,7 +572,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g) if (Memory < 3) { // Method will depend on cursor type - if ((Rbuf = Jcp->Rewind(Query->GetStr())) < 0) + if ((Rbuf = Query ? Jcp->Rewind(Query->GetStr()) : 0) < 0) if (Mode != MODE_READX) { Jcp->Close(); return true; @@ -605,6 +605,10 @@ bool TDBJDBC::OpenDB(PGLOBAL g) else if (Quoted) Quote = Jcp->GetQuoteChar(); + if (Mode != MODE_READ && Mode != MODE_READX) + if (Jcp->SetUUID(g, this)) + PushWarning(g, this, 1); + Use = USE_OPEN; // Do it now in case we are recursively called /*********************************************************************/ @@ -767,7 +771,7 @@ bool TDBJDBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) Mode = MODE_READ; } // endif's op - if (trace) + if (trace(33)) htrc("JDBC ReadKey: Query=%s\n", Query->GetStr()); rc = Jcp->ExecuteQuery((char*)Query->GetStr()); @@ -783,7 +787,7 @@ int TDBJDBC::ReadDB(PGLOBAL g) { int rc; - if (trace > 1) + if (trace(2)) htrc("JDBC ReadDB: R%d Mode=%d\n", GetTdb_No(), Mode); if (Mode == MODE_UPDATE || Mode == MODE_DELETE) { @@ -836,7 +840,7 @@ int TDBJDBC::ReadDB(PGLOBAL g) } // endif placed - if (trace > 1) + if (trace(2)) htrc(" Read: Rbuf=%d rc=%d\n", Rbuf, rc); return rc; @@ -897,7 +901,7 @@ int TDBJDBC::WriteDB(PGLOBAL g) Query->RepLast(')'); - if (trace > 1) + if (trace(2)) htrc("Inserting: %s\n", Query->GetStr()); rc = Jcp->ExecuteUpdate(Query->GetStr()); @@ -925,7 +929,7 @@ int TDBJDBC::DeleteDB(PGLOBAL g, int irc) AftRows = Jcp->m_Aff; sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); PushWarning(g, this, 0); // 0 means a Note @@ -946,14 +950,14 @@ void TDBJDBC::CloseDB(PGLOBAL g) if (Jcp) Jcp->Close(); - if (trace) + if (trace(1)) htrc("JDBC CloseDB: closing %s\n", Name); if (!Werr && (Mode == MODE_INSERT || Mode == MODE_UPDATE || Mode == MODE_DELETE)) { sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); PushWarning(g, this, 0); // 0 means a Note @@ -970,6 +974,7 @@ void TDBJDBC::CloseDB(PGLOBAL g) JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) : EXTCOL(cdp, tdbp, cprec, i, am) { + uuid = false; } // end of JDBCCOL constructor /***********************************************************************/ @@ -977,6 +982,7 @@ JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) /***********************************************************************/ JDBCCOL::JDBCCOL(void) : EXTCOL() { + uuid = false; } // end of JDBCCOL constructor /***********************************************************************/ @@ -985,12 +991,11 @@ JDBCCOL::JDBCCOL(void) : EXTCOL() /***********************************************************************/ JDBCCOL::JDBCCOL(JDBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp) { + uuid = col1->uuid; } // end of JDBCCOL copy constructor /***********************************************************************/ -/* ReadColumn: when SQLFetch is used there is nothing to do as the */ -/* column buffer was bind to the record set. This is also the case */ -/* when calculating MaxSize (Bufp is NULL even when Rows is not). */ +/* ReadColumn: retrieve the column value via the JDBC driver. */ /***********************************************************************/ void JDBCCOL::ReadColumn(PGLOBAL g) { @@ -1117,7 +1122,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g) { bool rc = false; - if (trace) + if (trace(1)) htrc("JDBC OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", this, Tdb_No, Use, Mode); diff --git a/storage/connect/tabjdbc.h b/storage/connect/tabjdbc.h index d422ed26ef2d0bbe0bbf0251b4cbd50913921bd4..078129a14e30c8d178e9251f958f36471b51ab57 100644 --- a/storage/connect/tabjdbc.h +++ b/storage/connect/tabjdbc.h @@ -101,6 +101,7 @@ class TDBJDBC : public TDBEXT { /***********************************************************************/ class JDBCCOL : public EXTCOL { friend class TDBJDBC; + friend class JDBConn; public: // Constructors JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "JDBC"); @@ -119,6 +120,7 @@ class JDBCCOL : public EXTCOL { JDBCCOL(void); // Members + bool uuid; // For PostgreSQL }; // end of class JDBCCOL /***********************************************************************/ diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 8778b7d4b4703c4dfde2f1fa3824e09cd454fe3a..9e4f5ab987d0e7d9b4e8f12aecccec5ccdd1384a 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -54,16 +54,16 @@ USETEMP UseTemp(void); char *GetJsonNull(void); -typedef struct _jncol { - struct _jncol *Next; - char *Name; - char *Fmt; - int Type; - int Len; - int Scale; - bool Cbn; - bool Found; -} JCOL, *PJCL; +//typedef struct _jncol { +// struct _jncol *Next; +// char *Name; +// char *Fmt; +// int Type; +// int Len; +// int Scale; +// bool Cbn; +// bool Found; +//} JCOL, *PJCL; /***********************************************************************/ /* JSONColumns: construct the result blocks containing the description */ @@ -76,26 +76,13 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - char *p, colname[65], fmt[129]; - int i, j, lvl, n = 0; + int i, n = 0; int ncol = sizeof(buftyp) / sizeof(int); - bool mgo = (GetTypeID(topt->type) == TAB_MONGO); - PCSZ sep, level; - PVAL valp; - JCOL jcol; - PJCL jcp, fjcp = NULL, pjcp = NULL; - PJPR *jrp, jpp; - PJSON jsp; - PJVAL jvp; - PJOB row; - PJDEF tdp; - TDBJSN *tjnp = NULL; - PJTDB tjsp = NULL; + PJCL jcp; + JSONDISC *pjdc = NULL; PQRYRES qrp; PCOLRES crp; - jcol.Name = jcol.Fmt = NULL; - if (info) { length[0] = 128; length[7] = 256; @@ -107,20 +94,100 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) return NULL; } // endif Multiple - /*********************************************************************/ - /* Open the input file. */ + pjdc = new(g) JSONDISC(g, length); + + if (!(n = pjdc->GetColumns(g, db, dsn, topt))) + return NULL; + + skipit: + if (trace(1)) + htrc("JSONColumns: n=%d len=%d\n", n, length[0]); + + /*********************************************************************/ + /* Allocate the structures used to refer to the result set. */ + /*********************************************************************/ + qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, + buftyp, fldtyp, length, false, false); + + crp = qrp->Colresp->Next->Next->Next->Next->Next->Next; + crp->Name = "Nullable"; + crp->Next->Name = "Jpath"; + + if (info || !qrp) + return qrp; + + qrp->Nblin = n; + /*********************************************************************/ - level = GetStringTableOption(g, topt, "Level", NULL); + /* Now get the results into blocks. */ + /*********************************************************************/ + for (i = 0, jcp = pjdc->fjcp; jcp; i++, jcp = jcp->Next) { + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; // Void column + + crp = qrp->Colresp; // Column Name + crp->Kdata->SetValue(jcp->Name, i); + crp = crp->Next; // Data Type + crp->Kdata->SetValue(jcp->Type, i); + crp = crp->Next; // Type Name + crp->Kdata->SetValue(GetTypeName(jcp->Type), i); + crp = crp->Next; // Precision + crp->Kdata->SetValue(jcp->Len, i); + crp = crp->Next; // Length + crp->Kdata->SetValue(jcp->Len, i); + crp = crp->Next; // Scale (precision) + crp->Kdata->SetValue(jcp->Scale, i); + crp = crp->Next; // Nullable + crp->Kdata->SetValue(jcp->Cbn ? 1 : 0, i); + crp = crp->Next; // Field format + + if (crp->Kdata) + crp->Kdata->SetValue(jcp->Fmt, i); + + } // endfor i + + /*********************************************************************/ + /* Return the result pointer. */ + /*********************************************************************/ + return qrp; + } // end of JSONColumns + +/* -------------------------- Class JSONDISC ------------------------- */ + +/***********************************************************************/ +/* Class used to get the columns of a JSON table. */ +/***********************************************************************/ +JSONDISC::JSONDISC(PGLOBAL g, uint *lg) +{ + length = lg; + jcp = fjcp = pjcp = NULL; + tjnp = NULL; + jpp = NULL; + tjsp = NULL; + jsp = NULL; + row = NULL; + sep = NULL; + i = n = bf = ncol = lvl = 0; + all = false; +} // end of JSONDISC constructor + +int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) +{ + bool mgo = (GetTypeID(topt->type) == TAB_MONGO); + PCSZ level = GetStringTableOption(g, topt, "Level", NULL); if (level) { lvl = atoi(level); lvl = (lvl > 16) ? 16 : lvl; - } else + } else lvl = 0; sep = GetStringTableOption(g, topt, "Separator", "."); - tdp = new(g) JSONDEF; + /*********************************************************************/ + /* Open the input file. */ + /*********************************************************************/ + tdp = new(g) JSONDEF; #if defined(ZIP_SUPPORT) tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL); tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false); @@ -128,23 +195,23 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); if (!(tdp->Database = SetPath(g, db))) - return NULL; + return 0; - tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); - tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; - tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; + tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL); tdp->Accept = GetBooleanTableOption(g, topt, "Accept", false); tdp->Uri = (dsn && *dsn ? dsn : NULL); if (!tdp->Fn && !tdp->Uri) { strcpy(g->Message, MSG(MISSING_FNAME)); - return NULL; + return 0; } // endif Fn - if (trace) - htrc("File %s objname=%s pretty=%d lvl=%d\n", - tdp->Fn, tdp->Objname, tdp->Pretty, lvl); + if (trace(1)) + htrc("File %s objname=%s pretty=%d lvl=%d\n", + tdp->Fn, tdp->Objname, tdp->Pretty, lvl); if (tdp->Uri) { #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) @@ -160,34 +227,34 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) tdp->Pretty = 0; #else // !MONGO_SUPPORT sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return NULL; + return 0; #endif // !MONGO_SUPPORT } // endif Uri - if (tdp->Pretty == 2) { + if (tdp->Pretty == 2) { if (tdp->Zipped) { #if defined(ZIP_SUPPORT) tjsp = new(g) TDBJSON(tdp, new(g) UNZFAM(tdp)); #else // !ZIP_SUPPORT sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); - return NULL; + return 0; #endif // !ZIP_SUPPORT - } else - tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); + } else + tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); - if (tjsp->MakeDocument(g)) - return NULL; + if (tjsp->MakeDocument(g)) + return 0; - jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; - } else { - if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) + jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; + } else { + if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) if (!mgo) { sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); - return NULL; - } else + return 0; + } else tdp->Lrecl = 8192; // Should be enough - tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); + tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); if (tdp->Zipped) { #if defined(ZIP_SUPPORT) @@ -196,36 +263,36 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); return NULL; #endif // !ZIP_SUPPORT - } else if (tdp->Uri) { + } else if (tdp->Uri) { if (tdp->Driver && toupper(*tdp->Driver) == 'C') { #if defined(CMGO_SUPPORT) tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); #else sprintf(g->Message, "Mongo %s Driver not available", "C"); - return NULL; + return 0; #endif - } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { + } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { #if defined(JAVA_SUPPORT) tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); #else sprintf(g->Message, "Mongo %s Driver not available", "Java"); - return NULL; + return 0; #endif - } else { // Driver not specified + } else { // Driver not specified #if defined(CMGO_SUPPORT) tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); #elif defined(JAVA_SUPPORT) tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); #else sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return NULL; + return 0; #endif } // endif Driver - } else + } else tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); - tjnp->SetMode(MODE_READ); + tjnp->SetMode(MODE_READ); // Allocate the parse work memory PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); @@ -237,248 +304,227 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) tjnp->SetG(G); if (tjnp->OpenDB(g)) - return NULL; + return 0; - switch (tjnp->ReadDB(g)) { - case RC_EF: - strcpy(g->Message, "Void json table"); - case RC_FX: - goto err; - default: - jsp = tjnp->GetRow(); - } // endswitch ReadDB + switch (tjnp->ReadDB(g)) { + case RC_EF: + strcpy(g->Message, "Void json table"); + case RC_FX: + goto err; + default: + jsp = tjnp->GetRow(); + } // endswitch ReadDB - } // endif pretty + } // endif pretty - if (!(row = (jsp) ? jsp->GetObject() : NULL)) { - strcpy(g->Message, "Can only retrieve columns from object rows"); - goto err; - } // endif row + if (!(row = (jsp) ? jsp->GetObject() : NULL)) { + strcpy(g->Message, "Can only retrieve columns from object rows"); + goto err; + } // endif row - jcol.Next = NULL; - jcol.Found = true; - colname[64] = 0; - fmt[128] = 0; + all = GetBooleanTableOption(g, topt, "Fullarray", false); + jcol.Name = jcol.Fmt = NULL; + jcol.Next = NULL; + jcol.Found = true; + colname[0] = 0; if (!tdp->Uri) { - *fmt = '$'; + fmt[0] = '$'; fmt[1] = '.'; - p = fmt + 2; - } else - p = fmt; - - jrp = (PJPR*)PlugSubAlloc(g, NULL, sizeof(PJPR) * MY_MAX(lvl, 0)); - - /*********************************************************************/ - /* Analyse the JSON tree and define columns. */ - /*********************************************************************/ - for (i = 1; ; i++) { - for (jpp = row->GetFirst(); jpp; jpp = jpp->GetNext()) { - for (j = 0; j < lvl; j++) - jrp[j] = NULL; - - more: - strncpy(colname, jpp->GetKey(), 64); - *p = 0; - j = 0; - jvp = jpp->GetVal(); - - retry: - if ((valp = jvp ? jvp->GetValue() : NULL)) { - jcol.Type = valp->GetType(); - jcol.Len = valp->GetValLen(); - jcol.Scale = valp->GetValPrec(); - jcol.Cbn = valp->IsNull(); - } else if (!jvp || jvp->IsNull()) { - jcol.Type = TYPE_UNKNOWN; - jcol.Len = jcol.Scale = 0; - jcol.Cbn = true; - } else if (j < lvl) { - if (!*p) - strcat(fmt, colname); - - jsp = jvp->GetJson(); - - switch (jsp->GetType()) { - case TYPE_JOB: - if (!jrp[j]) - jrp[j] = jsp->GetFirst(); - - if (*jrp[j]->GetKey() != '$') { - strncat(strncat(fmt, sep, 128), jrp[j]->GetKey(), 128); - strncat(strncat(colname, "_", 64), jrp[j]->GetKey(), 64); - } // endif Key - - jvp = jrp[j]->GetVal(); - j++; - break; - case TYPE_JAR: - if (!tdp->Xcol || stricmp(tdp->Xcol, colname)) { - if (tdp->Uri) - strncat(strncat(fmt, sep, 128), "0", 128); - else - strncat(fmt, "[0]", 128); - - } else - strncat(fmt, (tdp->Uri ? sep : "[]"), 128); - - jvp = jsp->GetValue(0); - break; - default: - sprintf(g->Message, "Logical error after %s", fmt); - goto err; - } // endswitch jsp - - goto retry; - } else if (lvl >= 0) { - jcol.Type = TYPE_STRING; - jcol.Len = 256; - jcol.Scale = 0; - jcol.Cbn = true; - } else - continue; + bf = 2; + } // endif Uri - // Check whether this column was already found - for (jcp = fjcp; jcp; jcp = jcp->Next) - if (!strcmp(colname, jcp->Name)) - break; - - if (jcp) { - if (jcp->Type != jcol.Type) { - if (jcp->Type == TYPE_UNKNOWN) - jcp->Type = jcol.Type; - else if (jcol.Type != TYPE_UNKNOWN) - jcp->Type = TYPE_STRING; + /*********************************************************************/ + /* Analyse the JSON tree and define columns. */ + /*********************************************************************/ + for (i = 1; ; i++) { + for (jpp = row->GetFirst(); jpp; jpp = jpp->GetNext()) { + strncpy(colname, jpp->GetKey(), 64); + fmt[bf] = 0; + + if (Find(g, jpp->GetVal(), MY_MIN(lvl, 0))) + goto err; + + } // endfor jpp + + // Missing column can be null + for (jcp = fjcp; jcp; jcp = jcp->Next) { + jcp->Cbn |= !jcp->Found; + jcp->Found = false; + } // endfor jcp + + if (tdp->Pretty != 2) { + // Read next record + switch (tjnp->ReadDB(g)) { + case RC_EF: + jsp = NULL; + break; + case RC_FX: + goto err; + default: + jsp = tjnp->GetRow(); + } // endswitch ReadDB - } // endif Type + } else + jsp = tjsp->GetDoc()->GetValue(i); - if (*p && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { - jcp->Fmt = PlugDup(g, fmt); - length[7] = MY_MAX(length[7], strlen(fmt)); - } // endif fmt - - jcp->Len = MY_MAX(jcp->Len, jcol.Len); - jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale); - jcp->Cbn |= jcol.Cbn; - jcp->Found = true; - } else if (jcol.Type != TYPE_UNKNOWN || tdp->Accept) { - // New column - jcp = (PJCL)PlugSubAlloc(g, NULL, sizeof(JCOL)); - *jcp = jcol; - jcp->Cbn |= (i > 1); - jcp->Name = PlugDup(g, colname); - length[0] = MY_MAX(length[0], strlen(colname)); - - if (*p) { - jcp->Fmt = PlugDup(g, fmt); - length[7] = MY_MAX(length[7], strlen(fmt)); - } else - jcp->Fmt = NULL; - - if (pjcp) { - jcp->Next = pjcp->Next; - pjcp->Next = jcp; - } else - fjcp = jcp; + if (!(row = (jsp) ? jsp->GetObject() : NULL)) + break; - n++; - } // endif jcp + } // endfor i - pjcp = jcp; + if (tdp->Pretty != 2) + tjnp->CloseDB(g); - for (j = lvl - 1; j >= 0; j--) - if (jrp[j] && (jrp[j] = jrp[j]->GetNext())) - goto more; + return n; - } // endfor jpp +err: + if (tdp->Pretty != 2) + tjnp->CloseDB(g); - // Missing column can be null - for (jcp = fjcp; jcp; jcp = jcp->Next) { - jcp->Cbn |= !jcp->Found; - jcp->Found = false; - } // endfor jcp + return 0; +} // end of GetColumns - if (tdp->Pretty != 2) { - // Read next record - switch (tjnp->ReadDB(g)) { - case RC_EF: - jsp = NULL; - break; - case RC_FX: - goto err; - default: - jsp = tjnp->GetRow(); - } // endswitch ReadDB +bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, int j) +{ + char *p, *pc = colname + strlen(colname); + int ars; + PJOB job; + PJAR jar; + + if ((valp = jvp ? jvp->GetValue() : NULL)) { + jcol.Type = valp->GetType(); + jcol.Len = valp->GetValLen(); + jcol.Scale = valp->GetValPrec(); + jcol.Cbn = valp->IsNull(); + } else if (!jvp || jvp->IsNull()) { + jcol.Type = TYPE_UNKNOWN; + jcol.Len = jcol.Scale = 0; + jcol.Cbn = true; + } else if (j < lvl) { + if (!fmt[bf]) + strcat(fmt, colname); + + p = fmt + strlen(fmt); + jsp = jvp->GetJson(); + + switch (jsp->GetType()) { + case TYPE_JOB: + job = (PJOB)jsp; + + for (PJPR jrp = job->GetFirst(); jrp; jrp = jrp->GetNext()) { + if (*jrp->GetKey() != '$') { + strncat(strncat(fmt, sep, 128), jrp->GetKey(), 128); + strncat(strncat(colname, "_", 64), jrp->GetKey(), 64); + } // endif Key + + if (Find(g, jrp->GetVal(), j + 1)) + return true; + + *p = *pc = 0; + } // endfor jrp + + return false; + case TYPE_JAR: + jar = (PJAR)jsp; + + if (all || (tdp->Xcol && !stricmp(tdp->Xcol, colname))) + ars = jar->GetSize(false); + else + ars = MY_MIN(jar->GetSize(false), 1); - } else - jsp = tjsp->GetDoc()->GetValue(i); + for (int k = 0; k < ars; k++) { + if (!tdp->Xcol || stricmp(tdp->Xcol, colname)) { + sprintf(buf, "%d", k); - if (!(row = (jsp) ? jsp->GetObject() : NULL)) - break; + if (tdp->Uri) + strncat(strncat(fmt, sep, 128), buf, 128); + else + strncat(strncat(strncat(fmt, "[", 128), buf, 128), "]", 128); - } // endor i + if (all) + strncat(strncat(colname, "_", 64), buf, 64); - if (tdp->Pretty != 2) - tjnp->CloseDB(g); + } else + strncat(fmt, (tdp->Uri ? sep : "[*]"), 128); - skipit: - if (trace) - htrc("JSONColumns: n=%d len=%d\n", n, length[0]); + if (Find(g, jar->GetValue(k), j)) + return true; - /*********************************************************************/ - /* Allocate the structures used to refer to the result set. */ - /*********************************************************************/ - qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3, - buftyp, fldtyp, length, false, false); + *p = *pc = 0; + } // endfor k - crp = qrp->Colresp->Next->Next->Next->Next->Next->Next; - crp->Name = "Nullable"; - crp->Next->Name = "Jpath"; + return false; + default: + sprintf(g->Message, "Logical error after %s", fmt); + return true; + } // endswitch Type - if (info || !qrp) - return qrp; + } else if (lvl >= 0) { + jcol.Type = TYPE_STRING; + jcol.Len = 256; + jcol.Scale = 0; + jcol.Cbn = true; + } else + return false; - qrp->Nblin = n; + AddColumn(g); + return false; +} // end of Find - /*********************************************************************/ - /* Now get the results into blocks. */ - /*********************************************************************/ - for (i = 0, jcp = fjcp; jcp; i++, jcp = jcp->Next) { - if (jcp->Type == TYPE_UNKNOWN) - jcp->Type = TYPE_STRING; // Void column +void JSONDISC::AddColumn(PGLOBAL g) +{ + bool b = fmt[bf] != 0; // True if formatted - crp = qrp->Colresp; // Column Name - crp->Kdata->SetValue(jcp->Name, i); - crp = crp->Next; // Data Type - crp->Kdata->SetValue(jcp->Type, i); - crp = crp->Next; // Type Name - crp->Kdata->SetValue(GetTypeName(jcp->Type), i); - crp = crp->Next; // Precision - crp->Kdata->SetValue(jcp->Len, i); - crp = crp->Next; // Length - crp->Kdata->SetValue(jcp->Len, i); - crp = crp->Next; // Scale (precision) - crp->Kdata->SetValue(jcp->Scale, i); - crp = crp->Next; // Nullable - crp->Kdata->SetValue(jcp->Cbn ? 1 : 0, i); - crp = crp->Next; // Field format + // Check whether this column was already found + for (jcp = fjcp; jcp; jcp = jcp->Next) + if (!strcmp(colname, jcp->Name)) + break; - if (crp->Kdata) - crp->Kdata->SetValue(jcp->Fmt, i); + if (jcp) { + if (jcp->Type != jcol.Type) { + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = jcol.Type; + else if (jcol.Type != TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; + + } // endif Type + + if (b && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { + jcp->Fmt = PlugDup(g, fmt); + length[7] = MY_MAX(length[7], strlen(fmt)); + } // endif fmt + + jcp->Len = MY_MAX(jcp->Len, jcol.Len); + jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale); + jcp->Cbn |= jcol.Cbn; + jcp->Found = true; + } else if (jcol.Type != TYPE_UNKNOWN || tdp->Accept) { + // New column + jcp = (PJCL)PlugSubAlloc(g, NULL, sizeof(JCOL)); + *jcp = jcol; + jcp->Cbn |= (i > 1); + jcp->Name = PlugDup(g, colname); + length[0] = MY_MAX(length[0], strlen(colname)); + + if (b) { + jcp->Fmt = PlugDup(g, fmt); + length[7] = MY_MAX(length[7], strlen(fmt)); + } else + jcp->Fmt = NULL; - } // endfor i + if (pjcp) { + jcp->Next = pjcp->Next; + pjcp->Next = jcp; + } else + fjcp = jcp; - /*********************************************************************/ - /* Return the result pointer. */ - /*********************************************************************/ - return qrp; + n++; + } // endif jcp -err: - if (tdp->Pretty != 2) - tjnp->CloseDB(g); + pjcp = jcp; +} // end of AddColumn - return NULL; - } // end of JSONColumns /* -------------------------- Class JSONDEF -------------------------- */ @@ -513,6 +559,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) Limit = GetIntCatInfo("Limit", 10); Base = GetIntCatInfo("Base", 0) ? 1 : 0; Sep = *GetStringCatInfo(g, "Separator", "."); + Accept = GetBoolCatInfo("Accept", false); if (Uri = GetStringCatInfo(g, "Connect", NULL)) { #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) @@ -1471,6 +1518,9 @@ void JSONCOL::ReadColumn(PGLOBAL g) if (!Tjp->SameRow || Xnod >= Tjp->SameRow) Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0)); + if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept) + throw("Null expandable JSON value"); + // Set null when applicable if (!Nullable) Value->SetNull(false); @@ -1546,11 +1596,16 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) /***********************************************************************/ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n) { - int ars; + int ars = MY_MIN(Tjp->Limit, arp->size()); PJVAL jvp; JVALUE jval; - ars = MY_MIN(Tjp->Limit, arp->size()); + if (!ars) { + Value->Reset(); + Value->SetNull(true); + Tjp->NextSame = 0; + return Value; + } // endif ars if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { strcpy(g->Message, "Logical error expanding array"); @@ -1591,14 +1646,14 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n) vp->Reset(); ars = MY_MIN(Tjp->Limit, arp->size()); - if (trace) + if (trace(1)) htrc("CalculateArray: size=%d op=%d nextsame=%d\n", ars, op, nextsame); for (i = 0; i < ars; i++) { jvrp = arp->GetValue(i); - if (trace) + if (trace(1)) htrc("i=%d nv=%d\n", i, nv); if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do { @@ -1612,7 +1667,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n) } else jvp = jvrp; - if (trace) + if (trace(1)) htrc("jvp=%s null=%d\n", jvp->GetString(g), jvp->IsNull() ? 1 : 0); @@ -1648,7 +1703,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n) if (err) vp->Reset(); - if (trace) { + if (trace(1)) { char buf(32); htrc("vp='%s' err=%d\n", diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 17583cba333f4cbe57dbe4859d6e4c417c342cd9..0341c0f8aa07119d77eb90bd17f70e89049949ad 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -15,6 +15,7 @@ enum JMODE {MODE_OBJECT, MODE_ARRAY, MODE_VALUE}; typedef class JSONDEF *PJDEF; typedef class TDBJSON *PJTDB; typedef class JSONCOL *PJCOL; +class TDBJSN; /***********************************************************************/ /* The JSON tree node. Can be an Object or an Array. */ @@ -29,6 +30,47 @@ typedef struct _jnode { int Nx; // Next to read row number } JNODE, *PJNODE; +typedef struct _jncol { + struct _jncol *Next; + char *Name; + char *Fmt; + int Type; + int Len; + int Scale; + bool Cbn; + bool Found; +} JCOL, *PJCL; + +/***********************************************************************/ +/* Class used to get the columns of a mongo collection. */ +/***********************************************************************/ +class JSONDISC : public BLOCK { +public: + // Constructor + JSONDISC(PGLOBAL g, uint *lg); + + // Functions + int GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt); + bool Find(PGLOBAL g, PJVAL jvp, int j); + void AddColumn(PGLOBAL g); + + // Members + JCOL jcol; + PJCL jcp, fjcp, pjcp; + PVAL valp; + PJDEF tdp; + TDBJSN *tjnp; + PJTDB tjsp; + PJPR jpp; + PJSON jsp; + PJOB row; + PCSZ sep; + char colname[65], fmt[129], buf[16]; + uint *length; + int i, n, bf, ncol, lvl; + bool all; +}; // end of JSONDISC + /***********************************************************************/ /* JSON table. */ /***********************************************************************/ @@ -36,13 +78,13 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */ friend class TDBJSON; friend class TDBJSN; friend class TDBJCL; + friend class JSONDISC; #if defined(CMGO_SUPPORT) friend class CMGFAM; #endif // CMGO_SUPPORT #if defined(JAVA_SUPPORT) friend class JMGFAM; #endif // JAVA_SUPPORT - friend PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool); public: // Constructor JSONDEF(void); diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp index 61aefc930821f41b4e65f938685091a1d96a0b8e..d4d3a34d67e7e5438eebf47b949b5425ec268bb8 100644 --- a/storage/connect/table.cpp +++ b/storage/connect/table.cpp @@ -128,7 +128,7 @@ PCOL TDB::ColDB(PGLOBAL g, PSZ name, int num) PCOLDEF cdp; PCOL cp, colp = NULL, cprec = NULL; - if (trace) + if (trace(1)) htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n", GetAmType(), SVP(name), Name, num); @@ -146,7 +146,7 @@ PCOL TDB::ColDB(PGLOBAL g, PSZ name, int num) else if (cp->GetIndex() < i) cprec = cp; - if (trace) + if (trace(1)) htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp); /*****************************************************************/ @@ -159,7 +159,7 @@ PCOL TDB::ColDB(PGLOBAL g, PSZ name, int num) else if (Mode != MODE_INSERT) colp = InsertSpcBlk(g, cdp); - if (trace) + if (trace(1)) htrc("colp=%p\n", colp); if (name || num) @@ -256,7 +256,7 @@ PCOL TDB::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) /***********************************************************************/ void TDB::MarkDB(PGLOBAL, PTDB tdb2) { - if (trace) + if (trace(1)) htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2); } // end of MarkDB @@ -416,7 +416,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) PCOLDEF cdp; PCOL cp, colp = NULL, cprec = NULL; - if (trace) + if (trace(1)) htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n", GetAmType(), SVP(name), Name, num); @@ -434,7 +434,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) else if (cp->GetIndex() < i) cprec = cp; - if (trace) + if (trace(1)) htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp); /*****************************************************************/ @@ -447,7 +447,7 @@ PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) else if (Mode != MODE_INSERT) colp = InsertSpcBlk(g, cdp); - if (trace) + if (trace(1)) htrc("colp=%p\n", colp); if (name || num) @@ -592,7 +592,7 @@ void TDBASE::PrintAM(FILE *f, char *m) /***********************************************************************/ void TDBASE::MarkDB(PGLOBAL, PTDB tdb2) { - if (trace) + if (trace(1)) htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2); } // end of MarkDB diff --git a/storage/connect/tabmac.cpp b/storage/connect/tabmac.cpp index a28b5d7108cb34cea8c84157fd449c2293d270e8..8260ab65391090b93cb07e1f60a0a562900bcc30 100644 --- a/storage/connect/tabmac.cpp +++ b/storage/connect/tabmac.cpp @@ -367,13 +367,13 @@ void MACCOL::ReadColumn(PGLOBAL g) case 11: // Description if ((p = strstr(adp->Description, " - Packet Scheduler Miniport"))) { strncpy(buf, adp->Description, p - adp->Description); - i = p - adp->Description; + i = (int)(p - adp->Description); strncpy(buf, adp->Description, i); buf[i] = 0; p = buf; } else if ((p = strstr(adp->Description, " - Miniport d'ordonnancement de paquets"))) { - i = p - adp->Description; + i = (int)(p - adp->Description); strncpy(buf, adp->Description, i); buf[i] = 0; p = buf; diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 0967afca6cdf933f49074d5cbf532028c94d4316..649fc6706c60693788fa6c78001f6efc155ec4a0 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -134,7 +134,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) PSZ filename; int rc, n = 0; - if (trace) + if (trace(1)) htrc("in InitFileName: fn[]=%d\n", FNSZ); filename = (char*)PlugSubAlloc(g, NULL, FNSZ); @@ -144,7 +144,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("InitFileName: fn='%s'\n", filename); if (Mul != 2) { @@ -159,7 +159,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) if (dirp->OpenDB(g)) return true; - if (trace && Mul == 3) { + if (trace(1) && Mul == 3) { int nf = ((PTDBSDR)dirp)->FindInDir(g); htrc("Number of files = %d\n", nf); } // endif trace @@ -319,7 +319,7 @@ int TDBMUL::GetMaxSize(PGLOBAL g) int i; int mxsz; - if (trace) + if (trace(1)) htrc("TDBMUL::GetMaxSize: Filenames=%p\n", Filenames); if (!Filenames && InitFileNames(g)) @@ -375,7 +375,7 @@ int TDBMUL::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ bool TDBMUL::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("MUL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", this, Tdb_No, Use, To_Key_Col, Mode); @@ -546,7 +546,7 @@ bool TDBMSD::InitFileNames(PGLOBAL g) PSZ filename; int rc, n = 0; - if (trace) + if (trace(1)) htrc("in InitFileName: fn[]=%d\n", FNSZ); filename = (char*)PlugSubAlloc(g, NULL, FNSZ); @@ -556,7 +556,7 @@ bool TDBMSD::InitFileNames(PGLOBAL g) PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("InitFileName: fn='%s'\n", filename); dirp = new(g) TDBSDR(filename); @@ -787,7 +787,7 @@ int TDBDIR::GetMaxSize(PGLOBAL g) /***********************************************************************/ bool TDBDIR::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("DIR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", this, Tdb_No, Use, Mode); @@ -985,7 +985,7 @@ void DIRCOL::SetTimeValue(PGLOBAL g, FILETIME& ftime) /***********************************************************************/ void DIRCOL::ReadColumn(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("DIR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", Name, Tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); @@ -1452,7 +1452,7 @@ int TDBDHR::GetMaxSize(PGLOBAL g) /***********************************************************************/ bool TDBDHR::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("DHR OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", this, Tdb_No, Use, Mode); @@ -1589,7 +1589,7 @@ void DHRCOL::ReadColumn(PGLOBAL g) int rc; PTDBDHR tdbp = (PTDBDHR)To_Tdb; - if (trace) + if (trace(1)) htrc("DHR ReadColumn: col %s R%d use=%.4X status=%.4X type=%d N=%d\n", Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type, N); diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index d1e2ae696085c89bea1e31376f10242426bc4e44..605b38224305e57a69cb24904fecc8105dda0b8c 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -124,8 +124,8 @@ bool MYSQLDEF::GetServerInfo(PGLOBAL g, const char *server_name) DBUG_RETURN(true); } // endif server - DBUG_PRINT("info", ("get_server_by_name returned server at %lx", - (size_t) server)); + DBUG_PRINT("info", ("get_server_by_name returned server at %p", + server)); // TODO: We need to examine which of these can really be NULL Hostname = PlugDup(g, server->host); @@ -203,7 +203,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b) // Otherwise, straight server name, Tabname = (b) ? GetStringCatInfo(g, "Tabname", Name) : NULL; - if (trace) + if (trace(1)) htrc("server: %s TableName: %s", url, Tabname); Server = url; @@ -567,7 +567,7 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx) return true; } // endif Query - if (trace) + if (trace(33)) htrc("Query=%s\n", Query->GetStr()); return false; @@ -681,7 +681,7 @@ bool TDBMYSQL::MakeCommand(PGLOBAL g) strlwr(strcpy(name, Name)); // Not a keyword if ((p = strstr(qrystr, name))) { - Query->Set(Qrystr, p - qrystr); + Query->Set(Qrystr, (uint)(p - qrystr)); if (qtd && *(p-1) == ' ') { Query->Append('`'); @@ -1042,7 +1042,7 @@ int TDBMYSQL::SendCommand(PGLOBAL g) sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); PushWarning(g, this, 0); // 0 means a Note - if (trace) + if (trace(1)) htrc("%s\n", g->Message); if (w && Myc.ExecSQL(g, "SHOW WARNINGS") == RC_OK) { @@ -1109,7 +1109,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) Mode = MODE_READ; } // endif's op - if (trace) + if (trace(33)) htrc("MYSQL ReadKey: Query=%s\n", Query->GetStr()); m_Rc = Myc.ExecSQL(g, Query->GetStr()); @@ -1124,7 +1124,7 @@ int TDBMYSQL::ReadDB(PGLOBAL g) { int rc; - if (trace > 1) + if (trace(2)) htrc("MySQL ReadDB: R%d Mode=%d\n", GetTdb_No(), Mode); if (Mode == MODE_UPDATE || Mode == MODE_DELETE) @@ -1137,7 +1137,7 @@ int TDBMYSQL::ReadDB(PGLOBAL g) N++; Fetched = ((rc = Myc.Fetch(g, -1)) == RC_OK); - if (trace > 1) + if (trace(2)) htrc(" Read: rc=%d\n", rc); return rc; @@ -1220,7 +1220,7 @@ void TDBMYSQL::CloseDB(PGLOBAL g) Myc.Close(); } // endif Myc - if (trace) + if (trace(1)) htrc("MySQL CloseDB: closing %s rc=%d\n", Name, m_Rc); } // end of CloseDB @@ -1248,7 +1248,7 @@ MYSQLCOL::MYSQLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) Slen = 0; Rank = -1; // Not known yet - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); } // end of MYSQLCOL constructor @@ -1279,7 +1279,7 @@ MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am) Slen = 0; Rank = i; - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); } // end of MYSQLCOL constructor @@ -1409,7 +1409,7 @@ void MYSQLCOL::ReadColumn(PGLOBAL g) tdbp->Fetched = true; if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank))) { - if (trace > 1) + if (trace(2)) htrc("MySQL ReadColumn: name=%s buf=%s\n", Name, buf); // TODO: have a true way to differenciate temporal values @@ -1679,7 +1679,7 @@ MYXCOL::MYXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) MYXCOL::MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am) : MYSQLCOL(fld, tdbp, i, am) { - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); } // end of MYSQLCOL constructor diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 56e5e72efd62f342bd813a23c345677c83e3805b..f7bc3934fbd5cc3d02540bd115be454be03c848d 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -289,7 +289,7 @@ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn) sprintf(Connect, MulConn, fn); } // endif MultConn - DBQ = (PSZ)fn; + DBQ = PlugDup(g, fn); } // end of SetFile /***********************************************************************/ @@ -538,7 +538,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) { bool rc = true; - if (trace) + if (trace(1)) htrc("ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d\n", this, Tdb_No, Use, Mode); @@ -750,7 +750,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) Mode = MODE_READ; } // endif's op - if (trace) + if (trace(33)) htrc("ODBC ReadKey: Query=%s\n", Query->GetStr()); Rows = Ocp->ExecDirectSQL((char*)Query->GetStr(), (PODBCCOL)Columns); @@ -765,7 +765,7 @@ int TDBODBC::ReadDB(PGLOBAL g) { int rc; - if (trace > 1) + if (trace(2)) htrc("ODBC ReadDB: R%d Mode=%d\n", GetTdb_No(), Mode); if (Mode == MODE_UPDATE || Mode == MODE_DELETE) { @@ -776,7 +776,7 @@ int TDBODBC::ReadDB(PGLOBAL g) if (!Ocp->ExecSQLcommand(Query->GetStr())) { sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); PushWarning(g, this, 0); // 0 means a Note @@ -817,7 +817,7 @@ int TDBODBC::ReadDB(PGLOBAL g) } // endif Placed - if (trace > 1) + if (trace(2)) htrc(" Read: Rbuf=%d rc=%d\n", Rbuf, rc); return rc; @@ -852,7 +852,7 @@ int TDBODBC::DeleteDB(PGLOBAL g, int irc) if (!Ocp->ExecSQLcommand(Query->GetStr())) { sprintf(g->Message, "%s: %d affected rows", TableName, AftRows); - if (trace) + if (trace(1)) htrc("%s\n", g->Message); PushWarning(g, this, 0); // 0 means a Note @@ -874,7 +874,7 @@ void TDBODBC::CloseDB(PGLOBAL g) Ocp->Close(); - if (trace) + if (trace(1)) htrc("ODBC CloseDB: closing %s\n", Name); } // end of CloseDB @@ -975,7 +975,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) } // endif Buf_Type - if (trace > 1) { + if (trace(2)) { char buf[64]; htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n", @@ -1214,7 +1214,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g) { bool rc = false; - if (trace) + if (trace(1)) htrc("ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d\n", this, Tdb_No, Use, Mode); diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 76a46e6899bf7bc80e43e4d45fb0be61a92e2e5a..da5d134f347003d328472c48304b749852c33aff 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -299,7 +299,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) Qryp->Nbcol += (ndif - 2); return Qryp; } catch (int n) { - if (trace) + if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); } catch (const char *msg) { strcpy(g->Message, msg); diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp index 7f0d9881298f9ce2501663f81c47a2035bcef826..f73a2b6578d2569dde51aba1d87655042d7ababb 100644 --- a/storage/connect/tabsys.cpp +++ b/storage/connect/tabsys.cpp @@ -180,7 +180,7 @@ PTDB TDBINI::Clone(PTABS t) /***********************************************************************/ char *TDBINI::GetSeclist(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("GetSeclist: Seclist=%p\n", Seclist); if (!Seclist) { @@ -267,7 +267,7 @@ bool TDBINI::OpenDB(PGLOBAL g) if (!colp->IsSpecial()) // Not a pseudo column colp->AllocBuf(g); - if (trace) + if (trace(1)) htrc("INI OpenDB: seclist=%s seclen=%d ifile=%s\n", Seclist, Seclen, Ifile); @@ -287,7 +287,7 @@ int TDBINI::ReadDB(PGLOBAL) else Section += (strlen(Section) + 1); - if (trace > 1) + if (trace(2)) htrc("INI ReadDB: section=%s N=%d\n", Section, N); N++; @@ -453,7 +453,7 @@ void INICOL::ReadColumn(PGLOBAL) { PTDBINI tdbp = (PTDBINI)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("INI ReadColumn: col %s R%d flag=%d\n", Name, tdbp->GetTdb_No(), Flag); @@ -493,7 +493,7 @@ void INICOL::WriteColumn(PGLOBAL g) bool rc; PTDBINI tdbp = (PTDBINI)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("INI WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, tdbp->GetTdb_No(), ColUse, Status); @@ -823,7 +823,7 @@ void XINCOL::WriteColumn(PGLOBAL g) bool rc; PTDBXIN tdbp = (PTDBXIN)To_Tdb; - if (trace > 1) + if (trace(2)) htrc("XIN WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, tdbp->GetTdb_No(), ColUse, Status); diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 7925e8f29a811b0e74a586e454621985612795f5..e194568ccf874791813162e7e60456303138b445 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -132,7 +132,7 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR, int) tbl = new(g) XTAB(pn, def); tbl->SetSchema(pdb); - if (trace) + if (trace(1)) htrc("TBL: Name=%s db=%s\n", tbl->GetName(), tbl->GetSchema()); // Link the blocks @@ -436,7 +436,7 @@ int TDBTBL::RowNumber(PGLOBAL g, bool b) /***********************************************************************/ bool TDBTBL::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("TBL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", this, Tdb_No, Use, To_Key_Col, Mode); @@ -475,7 +475,7 @@ bool TDBTBL::OpenDB(PGLOBAL g) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept) return TRUE; - if (trace) + if (trace(1)) htrc("Opening subtable %s\n", Tdbp->GetName()); // Now we can safely open the table @@ -530,7 +530,7 @@ int TDBTBL::ReadDB(PGLOBAL g) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept) return RC_FX; - if (trace) + if (trace(1)) htrc("Opening subtable %s\n", Tdbp->GetName()); // Now we can safely open the table @@ -555,7 +555,7 @@ int TDBTBL::ReadDB(PGLOBAL g) /***********************************************************************/ void TBTBLK::ReadColumn(PGLOBAL) { - if (trace) + if (trace(1)) htrc("TBT ReadColumn: name=%s\n", Name); Value->SetValue_psz((char*)((PTDBTBL)To_Tdb)->Tdbp->GetName()); @@ -575,27 +575,30 @@ pthread_handler_t ThreadOpen(void *p) if (!my_thread_init()) { set_current_thd(cmp->Thd); - if (trace) + if (trace(1)) htrc("ThreadOpen: Thd=%d\n", cmp->Thd); // Try to open the connection - if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { - pthread_mutex_lock(&tblmut); - if (trace) + pthread_mutex_lock(&tblmut); + + if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { +// pthread_mutex_lock(&tblmut); + if (trace(1)) htrc("Table %s ready\n", cmp->Tap->GetName()); cmp->Ready = true; - pthread_mutex_unlock(&tblmut); +// pthread_mutex_unlock(&tblmut); } else { - pthread_mutex_lock(&tblmut); - if (trace) +// pthread_mutex_lock(&tblmut); + if (trace(1)) htrc("Opening %s failed\n", cmp->Tap->GetName()); cmp->Rc = RC_FX; - pthread_mutex_unlock(&tblmut); +// pthread_mutex_unlock(&tblmut); } // endif OpenDB - my_thread_end(); + pthread_mutex_unlock(&tblmut); + my_thread_end(); } else cmp->Rc = RC_FX; @@ -672,7 +675,7 @@ bool TDBTBM::OpenTables(PGLOBAL g) // Remove remote table from the local list *ptabp = tabp->Next; - if (trace) + if (trace(1)) htrc("=====> New remote table %s\n", tabp->GetName()); // Make the remote table block @@ -698,7 +701,7 @@ bool TDBTBM::OpenTables(PGLOBAL g) ptp = &tp->Next; Nrc++; // Number of remote connections } else { - if (trace) + if (trace(1)) htrc("=====> Local table %s\n", tabp->GetName()); ptabp = &tabp->Next; @@ -714,7 +717,7 @@ bool TDBTBM::OpenTables(PGLOBAL g) /***********************************************************************/ bool TDBTBM::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("TBM OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", this, Tdb_No, Use, To_Key_Col, Mode); @@ -762,7 +765,7 @@ bool TDBTBM::OpenDB(PGLOBAL g) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept) return TRUE; - if (trace) + if (trace(1)) htrc("Opening subtable %s\n", Tdbp->GetName()); // Now we can safely open the table @@ -863,7 +866,7 @@ int TDBTBM::ReadNextRemote(PGLOBAL g) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept) return RC_FX; - if (trace) + if (trace(1)) htrc("Reading subtable %s\n", Tdbp->GetName()); return RC_OK; diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 5d8d7c1b9f86c85acddd3ee9c1d875aea940b739..68b66aec31fc867979e619dbcc8e23a0fbc15b73 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -457,7 +457,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) hc->get_table()->s->option_struct->srcdef = sp; } // endif s - if (trace && tdbp) + if (trace(1) && tdbp) htrc("Subtable %s in %s\n", name, SVP(tdbp->GetDef()->GetDB())); @@ -647,7 +647,7 @@ PRXCOL::PRXCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) Pseudo = false; Colnum = cdp->GetOffset(); // If columns are retrieved by number - if (trace) + if (trace(1)) htrc(" making new %sCOL C%d %s at %p\n", am, Index, Name, this); } // end of PRXCOL constructor @@ -732,7 +732,7 @@ void PRXCOL::Reset(void) /***********************************************************************/ void PRXCOL::ReadColumn(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("PRX ReadColumn: name=%s\n", Name); if (Colp) { @@ -759,7 +759,7 @@ void PRXCOL::ReadColumn(PGLOBAL g) /***********************************************************************/ void PRXCOL::WriteColumn(PGLOBAL g) { - if (trace > 1) + if (trace(2)) htrc("PRX WriteColumn: name=%s\n", Name); if (Colp) { diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 533986e44da5786647f92d188565a96c65b2d0c5..11b344ef65289c0184424cf0cc1bcd84f8fbe41e 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -304,7 +304,7 @@ bool TDBVCT::IsUsingTemp(PGLOBAL) /***********************************************************************/ bool TDBVCT::OpenDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", this, Tdb_No, Use, To_Key_Col, Mode); @@ -364,7 +364,7 @@ bool TDBVCT::OpenDB(PGLOBAL g) /***********************************************************************/ int TDBVCT::ReadDB(PGLOBAL g) { - if (trace) + if (trace(1)) htrc("VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n", GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum, To_Key_Col, To_Link, To_Kindex); @@ -546,7 +546,7 @@ void VCTCOL::ReadColumn(PGLOBAL g) assert (!To_Kcol); #endif - if (trace > 1) + if (trace(2)) htrc("VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type); @@ -574,7 +574,7 @@ void VCTCOL::WriteColumn(PGLOBAL) { PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;; - if (trace > 1) + if (trace(2)) htrc("VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type); diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index 335ffce5d7fa03750c7ade22c1b37262680e723e..8a8e1bcbcb62dea20ad9ca8812d7ef65f643ce82 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -34,7 +34,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname) HRESULT res; PWMIUT wp = (PWMIUT)PlugSubAlloc(g, NULL, sizeof(WMIUTIL)); - if (trace) + if (trace(1)) htrc("WMIColumns class %s space %s\n", SVP(classname), SVP(nsp)); /*********************************************************************/ @@ -103,7 +103,7 @@ PWMIUT InitWMI(PGLOBAL g, PCSZ nsp, PCSZ classname) loc->Release(); - if (trace) + if (trace(1)) htrc("Successfully connected to namespace.\n"); /*********************************************************************/ diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 6402f48e09042e70e31ec277e8e7464599ebb09e..c96e08444973013b0b6896495fab84c688c68f61 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -153,7 +153,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) lvl = (lvl < 0) ? 0 : (lvl > 16) ? 16 : lvl; } // endif fn - if (trace) + if (trace(1)) htrc("File %s lvl=%d\n", topt->filename, lvl); tdp = new(g) XMLDEF; @@ -362,7 +362,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) txmp->CloseDB(g); skipit: - if (trace) + if (trace(1)) htrc("XMLColumns: n=%d len=%d\n", n, length[0]); /*********************************************************************/ @@ -686,7 +686,7 @@ PTDB TDBXML::Clone(PTABS t) /***********************************************************************/ PCOL TDBXML::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) { - if (trace) + if (trace(1)) htrc("TDBXML: MakeCol %s n=%d\n", (cdp) ? cdp->GetName() : "", n); return new(g) XMLCOL(cdp, this, cprec, n); @@ -720,7 +720,7 @@ int TDBXML::LoadTableFile(PGLOBAL g, char *filename) if (Docp) return rc; // Already done - if (trace) + if (trace(1)) htrc("TDBXML: loading %s\n", filename); /*********************************************************************/ @@ -753,7 +753,7 @@ int TDBXML::LoadTableFile(PGLOBAL g, char *filename) return RC_FX; } // endif init - if (trace) + if (trace(1)) htrc("TDBXML: parsing %s rc=%d\n", filename, rc); // Parse the XML file @@ -1182,7 +1182,7 @@ int TDBXML::ReadDB(PGLOBAL g) } // endswitch recpos } else { - if (trace) + if (trace(1)) htrc("TDBXML ReadDB: Irow=%d Nrow=%d\n", Irow, Nrow); // This is to force the table to be expanded when constructing @@ -1209,7 +1209,7 @@ int TDBXML::ReadDB(PGLOBAL g) } // endif To_Kindex if (!same) { - if (trace > 1) + if (trace(2)) htrc("TDBXML ReadDB: Irow=%d RowNode=%p\n", Irow, RowNode); // Get the new row node @@ -1319,7 +1319,7 @@ void TDBXML::CloseDB(PGLOBAL g) Docp->CloseDoc(g, To_Xb); // This causes a crash in Diagnostics_area::set_error_status -// throw (int)TYPE_AM_XML; +// throw (int)TYPE_AM_XML; } // endif DumpDoc } // endif Changed @@ -1472,7 +1472,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) } else strcat(pbuf, Xname); - if (trace) + if (trace(1)) htrc("XMLCOL: pbuf=%s\n", pbuf); // For Update or Insert the Xpath must be analyzed @@ -1555,7 +1555,7 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) if (Type || Nod) Tdbp->Hasnod = true; - if (trace) + if (trace(1)) htrc("XMLCOL: Xname=%s\n", pbuf); // Save the calculated Xpath @@ -1679,7 +1679,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) int i, n, k = 0; PXNODE TopNode = NULL; - if (trace > 1) + if (trace(2)) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, Tdbp->GetTdb_No(), ColUse, Status); @@ -1913,7 +1913,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) int i, n, len, k = 0; PXNODE TopNode = NULL; - if (trace) + if (trace(1)) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, Tdbp->GetTdb_No(), ColUse, Status); @@ -2129,7 +2129,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g) char *p, buf[16]; int i, k, n; - if (trace) + if (trace(1)) htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n", Name, Tdbp->GetTdb_No(), ColUse, Status); diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index cb62667c0fe718c3ef5c0c06f13cd1f452687966..9532d7c2a8d2ebe69fb0236a2193e9abddf7ff1d 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -178,7 +178,7 @@ bool user_connect::CheckCleanup(bool force) g->Mrr = 0; last_query_id= thdp->query_id; - if (trace && !force) + if (trace(65) && !force) printf("=====> Begin new query %llu\n", last_query_id); return true; diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index 018c7ee3fe19f0cf0532e51fb4dd190bd182ddd3..73ca135691c3b3d53dfc9244e0fea245702c971f 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -53,7 +53,7 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, { PVBLK blkp; - if (trace) + if (trace(1)) htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n", mp, type, nval, len, check, blank); diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 74a3a1f807518629525e838d82130e4f4b71b076..e159efaa989235937c3ed62682159b1ae0d1c21f 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -337,7 +337,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type, short prec) { PVAL valp; - if (trace) + if (trace(1)) htrc("AllocateConstant: value=%p type=%hd\n", value, type); switch (type) { @@ -727,7 +727,7 @@ bool TYPVAL::SetValue_char(const char *p, int n) else Tval = (TYPE)val; - if (trace > 1) { + if (trace(2)) { char buf[64]; htrc(strcat(strcat(strcpy(buf, " setting %s to: "), Fmt), "\n"), GetTypeName(Type), Tval); @@ -750,7 +750,7 @@ bool TYPVAL::SetValue_char(const char *p, int n) buf[n] = '\0'; Tval = atof(buf); - if (trace > 1) + if (trace(2)) htrc(" setting double: '%s' -> %lf\n", buf, Tval); Null = false; @@ -996,7 +996,7 @@ int TYPVAL::CompareValue(PVAL vp) // Process filtering on numeric values. TYPE n = GetTypedValue(vp); -//if (trace) +//if (trace(1)) // htrc(" Comparing: val=%d,%d\n", Tval, n); return (Tval > n) ? 1 : (Tval < n) ? (-1) : 0; @@ -1384,7 +1384,7 @@ bool TYPVAL::SetValue_char(const char *cp, int n) strncpy(Strp, cp, n); Strp[n] = '\0'; - if (trace > 1) + if (trace(2)) htrc(" Setting string to: '%s'\n", Strp); } else @@ -1631,7 +1631,7 @@ int TYPVAL::CompareValue(PVAL vp) int n; //assert(vp->GetType() == Type); - if (trace) + if (trace(1)) htrc(" Comparing: val='%s','%s'\n", Strp, vp->GetCharValue()); // Process filtering on character strings. @@ -1656,14 +1656,14 @@ bool TYPVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) char *p[2], val[2][32]; int i; - if (trace) + if (trace(1)) htrc("Compute: np=%d op=%d\n", np, op); for (i = 0; i < np; i++) if (!vp[i]->IsNull()) { p[i] = vp[i]->GetCharString(val[i]); - if (trace) + if (trace(1)) htrc("p[%d]=%s\n", i, p[i]); } else @@ -1679,7 +1679,7 @@ bool TYPVAL::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) if ((i = Len - (signed)strlen(Strp)) > 0) strncat(Strp, p[np - 1], i); - if (trace) + if (trace(1)) htrc("Strp=%s\n", Strp); break; @@ -1747,7 +1747,7 @@ DECVAL::DECVAL(PSZ s) : TYPVAL(s) if (s) { char *p = strchr(Strp, '.'); - Prec = (p) ? Len - (p - Strp) : 0; + Prec = (p) ? (int)(Len - (p - Strp)) : 0; } // endif s Type = TYPE_DECIM; @@ -1854,7 +1854,7 @@ int DECVAL::CompareValue(PVAL vp) // Process filtering on numeric values. double f = atof(Strp), n = vp->GetFloatValue(); -//if (trace) +//if (trace(1)) // htrc(" Comparing: val=%d,%d\n", f, n); return (f > n) ? 1 : (f < n) ? (-1) : 0; @@ -2410,7 +2410,7 @@ void DTVAL::SetTimeShift(void) Shift = (int)mktime(&dtm) - 86400; - if (trace) + if (trace(1)) htrc("DTVAL Shift=%d\n", Shift); } // end of SetTimeShift @@ -2485,7 +2485,7 @@ bool DTVAL::MakeTime(struct tm *ptm) int n, y = ptm->tm_year; time_t t = mktime_mysql(ptm); - if (trace > 1) + if (trace(2)) htrc("MakeTime from (%d,%d,%d,%d,%d,%d)\n", ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); @@ -2508,7 +2508,7 @@ bool DTVAL::MakeTime(struct tm *ptm) } Tval= (int) t; - if (trace > 1) + if (trace(2)) htrc("MakeTime Ival=%d\n", Tval); return false; @@ -2528,14 +2528,14 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) datm.tm_mon=0; datm.tm_year=70; - if (trace > 1) + if (trace(2)) htrc("MakeDate from(%d,%d,%d,%d,%d,%d) nval=%d\n", val[0], val[1], val[2], val[3], val[4], val[5], nval); for (i = 0; i < nval; i++) { n = val[i]; -// if (trace > 1) +// if (trace(2)) // htrc("i=%d n=%d\n", i, n); switch (i) { @@ -2545,7 +2545,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) datm.tm_year = n; -// if (trace > 1) +// if (trace(2)) // htrc("n=%d tm_year=%d\n", n, datm.tm_year); break; @@ -2564,7 +2564,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) datm.tm_mon = m; datm.tm_year += n; -// if (trace > 1) +// if (trace(2)) // htrc("n=%d m=%d tm_year=%d tm_mon=%d\n", n, m, datm.tm_year, datm.tm_mon); break; @@ -2581,7 +2581,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) datm.tm_mday = m; datm.tm_year += n; -// if (trace > 1) +// if (trace(2)) // htrc("n=%d m=%d tm_year=%d tm_mon=%d\n", n, m, datm.tm_year, datm.tm_mon); break; @@ -2592,7 +2592,7 @@ bool DTVAL::MakeDate(PGLOBAL g, int *val, int nval) } // endfor i - if (trace > 1) + if (trace(2)) htrc("MakeDate datm=(%d,%d,%d,%d,%d,%d)\n", datm.tm_year, datm.tm_mon, datm.tm_mday, datm.tm_hour, datm.tm_min, datm.tm_sec); @@ -2656,7 +2656,7 @@ bool DTVAL::SetValue_char(const char *p, int n) // Trim trailing blanks for (p2 = p + n -1; p < p2 && *p2 == ' '; p2--); - if ((rc = (n = p2 - p + 1) > Len)) + if ((rc = (n = (int)(p2 - p + 1)) > Len)) n = Len; memcpy(Sdate, p, n); @@ -2667,7 +2667,7 @@ bool DTVAL::SetValue_char(const char *p, int n) ndv = ExtractDate(Sdate, Pdtp, DefYear, dval); MakeDate(NULL, dval, ndv); - if (trace > 1) + if (trace(2)) htrc(" setting date: '%s' -> %d\n", Sdate, Tval); Null = (Nullable && ndv == 0); @@ -2694,7 +2694,7 @@ void DTVAL::SetValue_psz(PCSZ p) ndv = ExtractDate(Sdate, Pdtp, DefYear, dval); MakeDate(NULL, dval, ndv); - if (trace > 1) + if (trace(2)) htrc(" setting date: '%s' -> %d\n", Sdate, Tval); Null = (Nullable && ndv == 0); @@ -2849,13 +2849,13 @@ bool DTVAL::FormatValue(PVAL vp, PCSZ fmt) char *buf = (char*)vp->GetTo_Val(); // Should be big enough struct tm tm, *ptm = GetGmTime(&tm); - if (trace > 1) + if (trace(2)) htrc("FormatValue: ptm=%p len=%d\n", ptm, vp->GetValLen()); if (ptm) { size_t n = strftime(buf, vp->GetValLen(), fmt, ptm); - if (trace > 1) + if (trace(2)) htrc("strftime: n=%d buf=%s\n", n, (n) ? buf : "???"); return (n == 0); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 30dce3b7fefc52b7999919bd4e7e0486b5110c02..efefc17b5f57a0f5fbedba58fd881c8a615c2bc5 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -344,7 +344,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } // endif n - if (trace) + if (trace(1)) htrc("XINDEX Make: n=%d\n", n); // File position must be stored @@ -417,7 +417,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) if (kcp->Init(g, colp, n, true, 0)) return true; - if (trace) + if (trace(1)) htrc("Adding colp=%p Buf_Type=%d size=%d\n", colp, colp->GetResultType(), n); @@ -484,7 +484,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } else To_Rec[nkey] = Tdbp->GetRecpos(); - if (trace > 1) + if (trace(2)) htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]); /*******************************************************************/ @@ -553,7 +553,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) if ((Ndif = Qsort(g, Num_K)) < 0) goto err; // Error during sort - if (trace) + if (trace(1)) htrc("Make: Nk=%d n=%d Num_K=%d Ndif=%d addcolp=%p BlkFil=%p X=%p\n", Nk, n, Num_K, Ndif, addcolp, Tdbp->To_BlkFil, X); @@ -883,7 +883,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) n[5] = Nblk; n[6] = Sblk; n[7] = Srtd ? 1 : 0; // Values are sorted in the file - if (trace) { + if (trace(1)) { htrc("Saving index %s\n", Xdp->GetName()); htrc("ID=%d Nk=%d nof=%d Num_K=%d Incr=%d Nblk=%d Sblk=%d Srtd=%d\n", ID, Nk, nof, Num_K, Incr, Nblk, Sblk, Srtd); @@ -926,7 +926,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) // dup->ProgCur += 5; } // endfor kcp - if (trace) + if (trace(1)) htrc("Index %s saved, Size=%d\n", Xdp->GetName(), size); end: @@ -1016,7 +1016,7 @@ bool XINDEX::Init(PGLOBAL g) PlugSetPath(fn, fn, Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("Index %s file: %s\n", Xdp->GetName(), fn); /*********************************************************************/ @@ -1039,7 +1039,7 @@ bool XINDEX::Init(PGLOBAL g) } else Srtd = false; - if (trace) + if (trace(1)) htrc("nv=%d %d %d %d %d %d %d (%d)\n", nv[0], nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd); @@ -1048,7 +1048,7 @@ bool XINDEX::Init(PGLOBAL g) if (/*nv[0] != ID ||*/ nv[1] != Nk) { sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); - if (trace) + if (trace(1)) htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk); goto err; @@ -1269,7 +1269,7 @@ bool XINDEX::MapInit(PGLOBAL g) PlugSetPath(fn, fn, Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("Index %s file: %s\n", Xdp->GetName(), fn); /*********************************************************************/ @@ -1300,7 +1300,7 @@ bool XINDEX::MapInit(PGLOBAL g) nv0 = nv[0]; } // endif nv - if (trace) + if (trace(1)) htrc("nv=%d %d %d %d %d %d %d %d\n", nv0, nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd); @@ -1310,7 +1310,7 @@ bool XINDEX::MapInit(PGLOBAL g) // Not this index sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); - if (trace) + if (trace(1)) htrc("nv0=%d ID=%d nv[1]=%d Nk=%d\n", nv0, ID, nv[1], Nk); goto err; @@ -1483,7 +1483,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) PlugSetPath(fn, fn, Tdbp->GetPath()); - if (trace) + if (trace(1)) htrc("Index %s file: %s\n", Xdp->GetName(), fn); /*********************************************************************/ @@ -1500,7 +1500,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) if (X->Read(g, nv, NZ, sizeof(int))) goto err; - if (trace) + if (trace(1)) htrc("nv=%d %d %d %d\n", nv[0], nv[1], nv[2], nv[3]); // The test on ID was suppressed because MariaDB can change an index ID @@ -1508,7 +1508,7 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk) if (/*nv[0] != ID ||*/ nv[1] != Nk) { sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); - if (trace) + if (trace(1)) htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk); goto err; @@ -1770,7 +1770,7 @@ int XINDEX::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file - if (trace > 1) + if (trace(2)) htrc("XINDEX Fetch: Op=%d\n", Op); /*********************************************************************/ @@ -1834,7 +1834,7 @@ int XINDEX::Fetch(PGLOBAL g) Nth++; - if (trace > 1) + if (trace(2)) htrc("Fetch: Looking for new value Nth=%d\n", Nth); Cur_K = FastFind(); @@ -1907,7 +1907,7 @@ int XINDEX::FastFind(void) sup = To_KeyCol->Ndf; } // endif Nblk - if (trace > 2) + if (trace(4)) htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", Nblk, Op, inf, sup); @@ -1985,7 +1985,7 @@ int XINDEX::FastFind(void) curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K; } // endfor kcp - if (trace > 2) + if (trace(4)) htrc("XINDEX FastFind: curk=%d\n", curk); return curk; @@ -2123,7 +2123,7 @@ int XINDXS::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file - if (trace > 1) + if (trace(2)) htrc("XINDXS Fetch: Op=%d\n", Op); /*********************************************************************/ @@ -2176,7 +2176,7 @@ int XINDXS::Fetch(PGLOBAL g) else Nth++; - if (trace > 1) + if (trace(2)) htrc("Fetch: Looking for new value Nth=%d\n", Nth); Cur_K = FastFind(); @@ -2243,7 +2243,7 @@ int XINDXS::FastFind(void) sup = Ndif; } // endif Nblk - if (trace > 2) + if (trace(4)) htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", Nblk, Op, inf, sup); @@ -2269,7 +2269,7 @@ int XINDXS::FastFind(void) n = 0; } // endif sup - if (trace > 2) + if (trace(4)) htrc("XINDXS FastFind: n=%d i=%d\n", n, i); // Loop on kcp because of dynamic indexing @@ -2337,7 +2337,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endswitch mode if (!(Xfile= global_fopen(g, MSGID_OPEN_ERROR_AND_STRERROR, filename, pmod))) { - if (trace) + if (trace(1)) htrc("Open: %s\n", g->Message); return true; @@ -2354,7 +2354,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) NewOff.v.Low = (int)ftell(Xfile); - if (trace) + if (trace(1)) htrc("XFILE Open: NewOff.v.Low=%d\n", NewOff.v.Low); } else if (mode == MODE_WRITE) { @@ -2365,7 +2365,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) fseek(Xfile, 0, SEEK_END); NewOff.v.Low = (int)ftell(Xfile); - if (trace) + if (trace(1)) htrc("XFILE Open: NewOff.v.Low=%d\n", NewOff.v.Low); } // endif id @@ -2377,7 +2377,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif MAX_INDX - if (trace) + if (trace(1)) htrc("XFILE Open: noff[%d].v.Low=%d\n", id, noff[id].v.Low); // Position the cursor at the offset of this index @@ -2510,7 +2510,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif - if (trace) + if (trace(1)) htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode); #if defined(__WIN__) @@ -2554,7 +2554,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif Hfile - if (trace) + if (trace(1)) htrc(" access=%p share=%p creation=%d handle=%p fn=%s\n", access, share, creation, Hfile, filename); @@ -2628,13 +2628,13 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) if (Hfile == INVALID_HANDLE_VALUE) { /*rc = errno;*/ - if (trace) + if (trace(1)) htrc("Open: %s\n", g->Message); return true; } // endif Hfile - if (trace) + if (trace(1)) htrc(" oflag=%p mode=%d handle=%d fn=%s\n", oflag, mode, Hfile, filename); @@ -2647,7 +2647,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif - if (trace) + if (trace(1)) htrc("INSERT: NewOff=%lld\n", NewOff.Val); } else if (mode == MODE_WRITE) { @@ -2657,7 +2657,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) NewOff.v.Low = write(Hfile, &noff, sizeof(noff)); } // endif id - if (trace) + if (trace(1)) htrc("WRITE: NewOff=%lld\n", NewOff.Val); } else if (mode == MODE_READ && id >= 0) { @@ -2667,7 +2667,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif read - if (trace) + if (trace(1)) htrc("noff[%d]=%lld\n", id, noff[id].Val); // Position the cursor at the offset of this index @@ -2705,13 +2705,13 @@ bool XHUGE::Seek(PGLOBAL g, int low, int high, int origin) if (lseek64(Hfile, pos, origin) < 0) { sprintf(g->Message, MSG(ERROR_IN_LSK), errno); - if (trace) + if (trace(1)) htrc("lseek64 error %d\n", errno); return true; } // endif lseek64 - if (trace) + if (trace(1)) htrc("Seek: low=%d high=%d\n", low, high); #endif // UNIX @@ -2750,13 +2750,13 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size) #else // UNIX ssize_t count = (ssize_t)(n * size); - if (trace) + if (trace(1)) htrc("Hfile=%d n=%d size=%d count=%d\n", Hfile, n, size, count); if (read(Hfile, buf, count) != count) { sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno)); - if (trace) + if (trace(1)) htrc("read error %d\n", errno); rc = true; @@ -2810,7 +2810,7 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) /***********************************************************************/ void XHUGE::Close(char *fn, int id) { - if (trace) + if (trace(1)) htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val); #if defined(__WIN__) @@ -3022,7 +3022,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln) Prefix = true; } // endif kln - if (trace) + if (trace(1)) htrc("KCOL(%p) Init: col=%s n=%d type=%d sm=%d\n", this, colp->GetName(), n, colp->GetResultType(), sm); @@ -3076,7 +3076,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) Type = colp->GetResultType(); - if (trace) + if (trace(1)) htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n", this, colp, Type, n[0], len, m); @@ -3196,7 +3196,7 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp) Valp->SetValue_pval(xp->GetValue(), false); } // endif Type - if (trace > 1) { + if (trace(2)) { char buf[32]; htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf)); @@ -3237,7 +3237,7 @@ int KXYCOL::Compare(int i1, int i2) // Do the actual comparison between values. register int k = Kblp->CompVal(i1, i2); - if (trace > 2) + if (trace(4)) htrc("Compare done result=%d\n", k); return (Asc) ? k : -k; @@ -3249,7 +3249,7 @@ int KXYCOL::Compare(int i1, int i2) int KXYCOL::CompVal(int i) { // Do the actual comparison between numerical values. - if (trace > 2) { + if (trace(4)) { register int k = (int)Kblp->CompVal(Valp, (int)i); htrc("Compare done result=%d\n", k); diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp index 02d3e974dcc883c3c6d9bb5112bee24883d6d667..c595ce5d6c43bdbd2c3b2d50ac38a03af2485751 100644 --- a/storage/connect/xobject.cpp +++ b/storage/connect/xobject.cpp @@ -204,7 +204,7 @@ STRING::STRING(PGLOBAL g, uint n, PCSZ str) *Strp = 0; Next = GetNext(); - Size = Next - Strp; + Size = (int)(Next - Strp); Trc = false; } else { // This should normally never happen @@ -239,7 +239,7 @@ char *STRING::Realloc(uint len) p = Strp; Next = GetNext(); - Size = Next - p; + Size = (int)(Next - p); return p; } // end of Realloc @@ -439,4 +439,3 @@ bool STRING::Resize(uint newsize) return newsize > Size; } // end of Resize - diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 7e0c61ff634d467adee1a998c8fcf6fa4f4de209..6659e529e975544efb062a65b17e45d11c6673e8 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -1788,7 +1788,7 @@ maria_declare_plugin(csv) &csv_storage_engine, "CSV", "Brian Aker, MySQL AB", - "CSV storage engine", + "Stores tables as CSV files", PLUGIN_LICENSE_GPL, tina_init_func, /* Plugin Init */ tina_done_func, /* Plugin Deinit */ diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 0e84546764d216208c74d3a51d89eefeaaf5e705..d234aa03edab50128cae616e7e2511da697eb392 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -3472,7 +3472,7 @@ maria_declare_plugin(federated) &federated_storage_engine, "FEDERATED", "Patrick Galbraith and Brian Aker, MySQL AB", - "Federated MySQL storage engine", + "Allows to access tables on other MariaDB servers", PLUGIN_LICENSE_GPL, federated_db_init, /* Plugin Init */ federated_done, /* Plugin Deinit */ diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 6c918575315e8b650ab969667eb6fdc98ed4a39a..50be6575a83c5acd7d183a36eb6a9697595f86ef 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -3647,7 +3647,7 @@ maria_declare_plugin(federatedx) &federatedx_storage_engine, "FEDERATED", "Patrick Galbraith", - "FederatedX pluggable storage engine", + "Allows to access tables on other MariaDB servers, supports transactions and more", PLUGIN_LICENSE_GPL, federatedx_db_init, /* Plugin Init */ federatedx_done, /* Plugin Deinit */ diff --git a/storage/heap/_check.c b/storage/heap/_check.c index 910a0d202563e7aa89d0dd0ad1075eeb6054d84b..fd8652d6a2acf51713b2feda2cc42df67b23be38 100644 --- a/storage/heap/_check.c +++ b/storage/heap/_check.c @@ -79,7 +79,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status) } hp_find_record(info,pos); - if (!info->current_ptr[share->reclength]) + if (!info->current_ptr[share->visible]) deleted++; else records++; diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 3513ddb4c2f38a2aa88461d5843fa54dc8e2a726..0298104c8aa4b4fe63d4a27fc706e6fe3d163111 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -91,15 +91,6 @@ ha_heap::ha_heap(handlerton *hton, TABLE_SHARE *table_arg) int ha_heap::open(const char *name, int mode, uint test_if_locked) { - if (table->s->reclength < sizeof (char*)) - { - MEM_UNDEFINED(table->s->default_values + table->s->reclength, - sizeof(char*) - table->s->reclength); - table->s->reclength= sizeof(char*); - MEM_UNDEFINED(table->record[0], table->s->reclength); - MEM_UNDEFINED(table->record[1], table->s->reclength); - } - internal_table= MY_TEST(test_if_locked & HA_OPEN_INTERNAL_TABLE); if (internal_table || (!(file= heap_open(name, mode)) && my_errno == ENOENT)) { @@ -714,7 +705,7 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table, } } } - mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*)); + mem_per_row+= MY_ALIGN(MY_MAX(share->reclength, sizeof(char*)) + 1, sizeof(char*)); if (table_arg->found_next_number_field) { keydef[share->next_number_index].flag|= HA_AUTO_KEY; diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index 431e992e75bbc8d58244964d9690b3214bd04a7f..ed669069b969f64792733c129fc3d450ce30156b 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -33,6 +33,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, uint keys= create_info->keys; ulong min_records= create_info->min_records; ulong max_records= create_info->max_records; + uint visible_offset; DBUG_ENTER("heap_create"); if (!create_info->internal_table) @@ -58,9 +59,9 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, /* We have to store sometimes uchar* del_link in records, - so the record length should be at least sizeof(uchar*) + so the visible_offset must be least at sizeof(uchar*) */ - set_if_bigger(reclength, sizeof (uchar*)); + visible_offset= MY_MAX(reclength, sizeof (char*)); for (i= key_segs= max_length= 0, keyinfo= keydef; i < keys; i++, keyinfo++) { @@ -154,7 +155,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, share->keydef= (HP_KEYDEF*) (share + 1); share->key_stat_version= 1; keyseg= (HA_KEYSEG*) (share->keydef + keys); - init_block(&share->block, reclength + 1, min_records, max_records); + init_block(&share->block, visible_offset + 1, min_records, max_records); /* Fix keys */ memcpy(share->keydef, keydef, (size_t) (sizeof(keydef[0]) * keys)); for (i= 0, keyinfo= share->keydef; i < keys; i++, keyinfo++) @@ -196,6 +197,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, share->max_table_size= create_info->max_table_size; share->data_length= share->index_length= 0; share->reclength= reclength; + share->visible= visible_offset; share->blength= 1; share->keys= keys; share->max_key_length= max_length; diff --git a/storage/heap/hp_delete.c b/storage/heap/hp_delete.c index 0c1c2c4c8f8f80cb4b294f02f5dd45d70d74e386..3f02e28a31b0593753d6a6cc3fb893295dee64b4 100644 --- a/storage/heap/hp_delete.c +++ b/storage/heap/hp_delete.c @@ -45,7 +45,7 @@ int heap_delete(HP_INFO *info, const uchar *record) info->update=HA_STATE_DELETED; *((uchar**) pos)=share->del_link; share->del_link=pos; - pos[share->reclength]=0; /* Record deleted */ + pos[share->visible]=0; /* Record deleted */ share->deleted++; share->key_version++; #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG) diff --git a/storage/heap/hp_rrnd.c b/storage/heap/hp_rrnd.c index 6bf1888275e4b71914dd1feb875c577c0afa35aa..1f2a26cb3ed0a81e94b1b9110d3521ad803e7ea8 100644 --- a/storage/heap/hp_rrnd.c +++ b/storage/heap/hp_rrnd.c @@ -37,7 +37,7 @@ int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos) info->update= 0; DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); } - if (!info->current_ptr[share->reclength]) + if (!info->current_ptr[share->visible]) { info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED); diff --git a/storage/heap/hp_rsame.c b/storage/heap/hp_rsame.c index 40c5a18f974dfcc946ffb6580ed80ce117559f4e..19767fd752be142c39dbd3e10433e72e55016013 100644 --- a/storage/heap/hp_rsame.c +++ b/storage/heap/hp_rsame.c @@ -32,7 +32,7 @@ int heap_rsame(register HP_INFO *info, uchar *record, int inx) DBUG_ENTER("heap_rsame"); test_active(info); - if (info->current_ptr[share->reclength]) + if (info->current_ptr[share->visible]) { if (inx < -1 || inx >= (int) share->keys) { diff --git a/storage/heap/hp_scan.c b/storage/heap/hp_scan.c index 39a6f2082a31bdab323dade8419af4a6516310b4..65726c37e1fa18611c449a47c764bfd44f638d48 100644 --- a/storage/heap/hp_scan.c +++ b/storage/heap/hp_scan.c @@ -62,7 +62,7 @@ int heap_scan(register HP_INFO *info, uchar *record) } hp_find_record(info, pos); } - if (!info->current_ptr[share->reclength]) + if (!info->current_ptr[share->visible]) { DBUG_PRINT("warning",("Found deleted record")); info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c index a1d81fd808dbb6bf67d8737805553f542846abe2..fc1e82bab4244078ad0a90ad479702e61915fe44 100644 --- a/storage/heap/hp_write.c +++ b/storage/heap/hp_write.c @@ -54,7 +54,7 @@ int heap_write(HP_INFO *info, const uchar *record) } memcpy(pos,record,(size_t) share->reclength); - pos[share->reclength]=1; /* Mark record as not deleted */ + pos[share->visible]= 1; /* Mark record as not deleted */ if (++share->records == share->blength) share->blength+= share->blength; info->s->key_version++; @@ -92,7 +92,7 @@ int heap_write(HP_INFO *info, const uchar *record) share->deleted++; *((uchar**) pos)=share->del_link; share->del_link=pos; - pos[share->reclength]=0; /* Record deleted */ + pos[share->visible]= 0; /* Record deleted */ DBUG_RETURN(my_errno); } /* heap_write */ diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 7eecefc90fdf5928f7e4c90742b8a9d7288f0961..2a45f05c463605767f6b6c1d09d2564e5b6a69a5 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -520,4 +520,6 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE MODULE_OUTPUT_NAME ha_innodb LINK_LIBRARIES ${ZLIB_LIBRARY} ${LIBSYSTEMD} ${LINKER_SCRIPT}) -ADD_DEPENDENCIES(innobase GenError) +IF(TARGET innobase) + ADD_DEPENDENCIES(innobase GenError) +ENDIF() diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index ca4c90eef41e8d407a59972b4319b5db4d6718ba..9f17815cd43ca2d2a962702867cd4460a59efdfb 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -39,57 +39,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com #include -/**************************************************//** -Custom nullptr implementation for under g++ 4.6 -*******************************************************/ -// #pragma once -/* -namespace std -{ - // based on SC22/WG21/N2431 = J16/07-0301 - struct nullptr_t - { - template operator any * () const - { - return 0; - } - template operator T any:: * () const - { - return 0; - } - -#ifdef _MSC_VER - struct pad {}; - pad __[sizeof(void*)/sizeof(pad)]; -#else - char __[sizeof(void*)]; -#endif -private: - // nullptr_t();// {} - // nullptr_t(const nullptr_t&); - // void operator = (const nullptr_t&); - void operator &() const; - template void operator +(any) const - { - // I Love MSVC 2005! - } - template void operator -(any) const - { - // I Love MSVC 2005! - } - }; -static const nullptr_t __nullptr = {}; -} - -#ifndef nullptr -#define nullptr std::__nullptr -#endif -*/ - -/**************************************************//** -End of Custom nullptr implementation for under g++ 4.6 -*******************************************************/ - /* When there's no work, either because defragment is disabled, or because no query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ #define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index e36e6d6194c33a34fef15162218627375e5903af..bd5cd02aa7500b963cef94e3b3ec2e3ac09243f4 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -2,6 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. +Copyright (c) 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -1250,17 +1251,11 @@ btr_search_drop_page_hash_index( mem_free(folds); } -/********************************************************************//** -Drops a possible page hash index when a page is evicted from the buffer pool -or freed in a file segment. */ +/** Drop possible adaptive hash index entries when a page is evicted +from the buffer pool or freed in a file, or the index is being dropped. */ UNIV_INTERN void -btr_search_drop_page_hash_when_freed( -/*=================================*/ - ulint space, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ - ulint page_no) /*!< in: page number */ +btr_search_drop_page_hash_when_freed(ulint space, ulint page_no) { buf_block_t* block; mtr_t mtr; @@ -1273,7 +1268,7 @@ btr_search_drop_page_hash_when_freed( are possibly holding, we cannot s-latch the page, but must (recursively) x-latch it, even though we are only reading. */ - block = buf_page_get_gen(space, zip_size, page_no, RW_X_LATCH, NULL, + block = buf_page_get_gen(space, 0, page_no, RW_X_LATCH, NULL, BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__, &mtr); diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 369f62d6483dfb3b1270f467936694efa2ec0140..1386fd63cc369e1c58c14b6786b270f28fd687b3 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -354,14 +354,142 @@ on the io_type */ ? (counter##_READ) \ : (counter##_WRITTEN)) + +/** Reserve a buffer slot for encryption, decryption or page compression. +@param[in,out] buf_pool buffer pool +@return reserved buffer slot */ +static buf_tmp_buffer_t* buf_pool_reserve_tmp_slot(buf_pool_t* buf_pool) +{ + for (ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) { + buf_tmp_buffer_t* slot = &buf_pool->tmp_arr->slots[i]; + if (slot->acquire()) { + return slot; + } + } + + /* We assume that free slot is found */ + ut_error; + return NULL; +} + +/** Reserve a buffer for encryption, decryption or decompression. +@param[in,out] slot reserved slot */ +static void buf_tmp_reserve_crypt_buf(buf_tmp_buffer_t* slot) +{ + if (!slot->crypt_buf) { + slot->crypt_buf = static_cast( + aligned_malloc(srv_page_size, srv_page_size)); + } +} + +/** Reserve a buffer for compression. +@param[in,out] slot reserved slot */ +static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot) +{ + if (!slot->comp_buf) { + /* Both snappy and lzo compression methods require that + output buffer used for compression is bigger than input + buffer. Increase the allocated buffer size accordingly. */ + ulint size = srv_page_size; +#ifdef HAVE_LZO + size += LZO1X_1_15_MEM_COMPRESS; +#elif defined HAVE_SNAPPY + size = snappy_max_compressed_length(size); +#endif + slot->comp_buf = static_cast( + aligned_malloc(size, srv_page_size)); + } +} + /** Decrypt a page. @param[in,out] bpage Page control block @param[in,out] space tablespace @return whether the operation was successful */ -static -bool -buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) - MY_ATTRIBUTE((nonnull)); +static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) +{ + ut_ad(space->n_pending_ios > 0); + ut_ad(space->id == bpage->space); + + byte* dst_frame = bpage->zip.data ? bpage->zip.data : + ((buf_block_t*) bpage)->frame; + bool page_compressed = fil_page_is_compressed(dst_frame); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + if (bpage->offset == 0) { + /* File header pages are not encrypted/compressed */ + return true; + } + + /* Page is encrypted if encryption information is found from + tablespace and page contains used key_version. This is true + also for pages first compressed and then encrypted. */ + + buf_tmp_buffer_t* slot; + + if (page_compressed) { + /* the page we read is unencrypted */ + /* Find free slot from temporary memory array */ +decompress: + slot = buf_pool_reserve_tmp_slot(buf_pool); + /* For decompression, use crypt_buf. */ + buf_tmp_reserve_crypt_buf(slot); +decompress_with_slot: + ut_d(fil_page_type_validate(dst_frame)); + + bpage->write_size = fil_page_decompress(slot->crypt_buf, + dst_frame); + slot->release(); + + ut_ad(!bpage->write_size || fil_page_type_validate(dst_frame)); + ut_ad(space->n_pending_ios > 0); + return bpage->write_size != 0; + } + + if (space->crypt_data + && mach_read_from_4(FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + + dst_frame)) { + /* Verify encryption checksum before we even try to + decrypt. */ + if (!fil_space_verify_crypt_checksum( + dst_frame, buf_page_get_zip_size(bpage), NULL, + bpage->offset)) { +decrypt_failed: + /* Mark page encrypted in case it should be. */ + if (space->crypt_data->type + != CRYPT_SCHEME_UNENCRYPTED) { + bpage->encrypted = true; + } + + return false; + } + + /* Find free slot from temporary memory array */ + slot = buf_pool_reserve_tmp_slot(buf_pool); + buf_tmp_reserve_crypt_buf(slot); + + ut_d(fil_page_type_validate(dst_frame)); + + /* decrypt using crypt_buf to dst_frame */ + if (!fil_space_decrypt(space, slot->crypt_buf, + dst_frame, &bpage->encrypted)) { + slot->release(); + goto decrypt_failed; + } + + ut_d(fil_page_type_validate(dst_frame)); + + if (fil_page_is_compressed_encrypted(dst_frame)) { + goto decompress_with_slot; + } + + slot->release(); + } else if (fil_page_is_compressed_encrypted(dst_frame)) { + goto decompress; + } + + ut_ad(space->n_pending_ios > 0); + return true; +} /********************************************************************//** Mark a table with the specified space pointed by bpage->space corrupted. @@ -3075,17 +3203,18 @@ buf_page_get_gen( #ifdef UNIV_DEBUG switch (mode) { case BUF_EVICT_IF_IN_POOL: + case BUF_PEEK_IF_IN_POOL: /* After DISCARD TABLESPACE, the tablespace would not exist, but in IMPORT TABLESPACE, PageConverter::operator() must replace any old pages, which were not evicted during DISCARD. - Skip the assertion on zip_size. */ + Similarly, btr_search_drop_page_hash_when_freed() must + remove any old pages. Skip the assertion on zip_size. */ break; case BUF_GET_NO_LATCH: ut_ad(rw_latch == RW_NO_LATCH); /* fall through */ case BUF_GET: case BUF_GET_IF_IN_POOL: - case BUF_PEEK_IF_IN_POOL: case BUF_GET_IF_IN_POOL_OR_WATCH: case BUF_GET_POSSIBLY_FREED: ut_ad(zip_size == fil_space_get_zip_size(space)); @@ -3189,6 +3318,11 @@ buf_page_get_gen( ibuf_inside(mtr)); retries = 0; + } else if (mode == BUF_GET_POSSIBLY_FREED) { + if (err) { + *err = local_err; + } + return NULL; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; @@ -3252,7 +3386,8 @@ buf_page_get_gen( fix_mutex = buf_page_get_mutex(&fix_block->page); - ut_ad(page_zip_get_size(&block->page.zip) == zip_size); + ut_ad(page_zip_get_size(&block->page.zip) == zip_size + || mode == BUF_PEEK_IF_IN_POOL); switch (mode) { case BUF_GET_IF_IN_POOL: @@ -3453,6 +3588,8 @@ buf_page_get_gen( buf_block_unfix(fix_block); buf_pool_mutex_exit(buf_pool); rw_lock_x_unlock(&fix_block->lock); + + *err = DB_PAGE_CORRUPTED; return NULL; } } @@ -4737,9 +4874,9 @@ buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) ib_logf(IB_LOG_LEVEL_ERROR, "The page [page id: space=%u" ", page number=%u]" - " in file %s cannot be decrypted.", + " in file '%s' cannot be decrypted.", bpage->space, bpage->offset, - space->name); + space->chain.start->name); ib_logf(IB_LOG_LEVEL_INFO, "However key management plugin or used key_version " ULINTPF @@ -4775,7 +4912,6 @@ buf_page_io_complete(buf_page_t* bpage, bool evict) buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); const ibool uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); - byte* frame = NULL; dberr_t err = DB_SUCCESS; ut_a(buf_page_in_file(bpage)); @@ -4793,19 +4929,18 @@ buf_page_io_complete(buf_page_t* bpage, bool evict) ulint read_page_no = 0; ulint read_space_id = 0; uint key_version = 0; - - ut_ad(bpage->zip.data || ((buf_block_t*)bpage)->frame); + byte* frame = bpage->zip.data + ? bpage->zip.data + : reinterpret_cast(bpage)->frame; + ut_ad(frame); fil_space_t* space = fil_space_acquire_for_io(bpage->space); if (!space) { return(DB_TABLESPACE_DELETED); } - buf_page_decrypt_after_read(bpage, space); - - if (buf_page_get_zip_size(bpage)) { - frame = bpage->zip.data; - } else { - frame = ((buf_block_t*) bpage)->frame; + if (!buf_page_decrypt_after_read(bpage, space)) { + err = DB_DECRYPTION_FAILED; + goto database_corrupted; } if (buf_page_get_zip_size(bpage)) { @@ -4969,7 +5104,7 @@ buf_page_io_complete(buf_page_t* bpage, bool evict) /* io_type == BUF_IO_WRITE */ if (bpage->slot) { /* Mark slot free */ - bpage->slot->reserved = false; + bpage->slot->release(); bpage->slot = NULL; } } @@ -6224,66 +6359,6 @@ buf_page_init_for_backup_restore( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************//** -Reserve unused slot from temporary memory array and allocate necessary -temporary memory if not yet allocated. -@return reserved slot */ -UNIV_INTERN -buf_tmp_buffer_t* -buf_pool_reserve_tmp_slot( -/*======================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool where to - reserve */ - bool compressed) /*!< in: is file space compressed */ -{ - buf_tmp_buffer_t *free_slot=NULL; - - /* Array is protected by buf_pool mutex */ - buf_pool_mutex_enter(buf_pool); - - for(ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) { - buf_tmp_buffer_t *slot = &buf_pool->tmp_arr->slots[i]; - - if(slot->reserved == false) { - free_slot = slot; - break; - } - } - - /* We assume that free slot is found */ - ut_a(free_slot != NULL); - free_slot->reserved = true; - /* Now that we have reserved this slot we can release - buf_pool mutex */ - buf_pool_mutex_exit(buf_pool); - - /* Allocate temporary memory for encryption/decryption */ - if (free_slot->crypt_buf == NULL) { - free_slot->crypt_buf = static_cast(aligned_malloc(UNIV_PAGE_SIZE, UNIV_PAGE_SIZE)); - memset(free_slot->crypt_buf, 0, UNIV_PAGE_SIZE); - } - - /* For page compressed tables allocate temporary memory for - compression/decompression */ - if (compressed && free_slot->comp_buf == NULL) { - ulint size = UNIV_PAGE_SIZE; - - /* Both snappy and lzo compression methods require that - output buffer used for compression is bigger than input - buffer. Increase the allocated buffer size accordingly. */ -#if HAVE_SNAPPY - size = snappy_max_compressed_length(size); -#endif -#if HAVE_LZO - size += LZO1X_1_15_MEM_COMPRESS; -#endif - free_slot->comp_buf = static_cast(aligned_malloc(size, UNIV_PAGE_SIZE)); - memset(free_slot->comp_buf, 0, size); - } - - return (free_slot); -} - /** Encryption and page_compression hook that is called just before a page is written to disk. @param[in,out] space tablespace @@ -6333,16 +6408,18 @@ buf_page_encrypt_before_write( } ulint zip_size = buf_page_get_zip_size(bpage); - ulint page_size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; + ut_ad(!zip_size || !page_compressed); buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); /* Find free slot from temporary memory array */ - buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); + buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool); slot->out_buf = NULL; bpage->slot = slot; + buf_tmp_reserve_crypt_buf(slot); byte *dst_frame = slot->crypt_buf; if (!page_compressed) { +not_compressed: /* Encrypt page content */ byte* tmp = fil_space_encrypt(space, bpage->offset, @@ -6350,32 +6427,28 @@ buf_page_encrypt_before_write( src_frame, dst_frame); - bpage->real_size = page_size; + bpage->real_size = UNIV_PAGE_SIZE; slot->out_buf = dst_frame = tmp; ut_d(fil_page_type_validate(tmp)); } else { /* First we compress the page content */ - ulint out_len = 0; - - byte *tmp = fil_compress_page( - space, - (byte *)src_frame, - slot->comp_buf, - page_size, + buf_tmp_reserve_compression_buf(slot); + byte* tmp = slot->comp_buf; + ulint out_len = fil_page_compress( + src_frame, tmp, fsp_flags_get_page_compression_level(space->flags), fil_space_get_block_size(space, bpage->offset), - encrypted, - &out_len); + encrypted); + if (!out_len) { + goto not_compressed; + } bpage->real_size = out_len; -#ifdef UNIV_DEBUG - fil_page_type_validate(tmp); -#endif - - if(encrypted) { + ut_d(fil_page_type_validate(tmp)); + if (encrypted) { /* And then we encrypt the page content */ tmp = fil_space_encrypt(space, bpage->offset, @@ -6387,131 +6460,9 @@ buf_page_encrypt_before_write( slot->out_buf = dst_frame = tmp; } -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif + ut_d(fil_page_type_validate(dst_frame)); // return dst_frame which will be written return dst_frame; } - -/** Decrypt a page. -@param[in,out] bpage Page control block -@param[in,out] space tablespace -@return whether the operation was successful */ -static -bool -buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) -{ - ut_ad(space->n_pending_ios > 0); - ut_ad(space->id == bpage->space); - - ulint zip_size = buf_page_get_zip_size(bpage); - ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; - - byte* dst_frame = (zip_size) ? bpage->zip.data : - ((buf_block_t*) bpage)->frame; - unsigned key_version = - mach_read_from_4(dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - bool page_compressed = fil_page_is_compressed(dst_frame); - bool page_compressed_encrypted = fil_page_is_compressed_encrypted(dst_frame); - buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - bool success = true; - - if (bpage->offset == 0) { - /* File header pages are not encrypted/compressed */ - return (true); - } - - /* Page is encrypted if encryption information is found from - tablespace and page contains used key_version. This is true - also for pages first compressed and then encrypted. */ - if (!space->crypt_data) { - key_version = 0; - } - - if (page_compressed) { - /* the page we read is unencrypted */ - /* Find free slot from temporary memory array */ - buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - - /* decompress using comp_buf to dst_frame */ - fil_decompress_page(slot->comp_buf, - dst_frame, - ulong(size), - &bpage->write_size); - - /* Mark this slot as free */ - slot->reserved = false; - key_version = 0; - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - } else { - buf_tmp_buffer_t* slot = NULL; - - if (key_version) { - /* Verify encryption checksum before we even try to - decrypt. */ - if (!fil_space_verify_crypt_checksum(dst_frame, - zip_size, NULL, bpage->offset)) { - - /* Mark page encrypted in case it should - be. */ - if (space->crypt_data->type - != CRYPT_SCHEME_UNENCRYPTED) { - bpage->encrypted = true; - } - - return (false); - } - - /* Find free slot from temporary memory array */ - slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - - /* decrypt using crypt_buf to dst_frame */ - if (!fil_space_decrypt(space, slot->crypt_buf, - dst_frame, &bpage->encrypted)) { - success = false; - } - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - } - - if (page_compressed_encrypted && success) { - if (!slot) { - slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - } - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - /* decompress using comp_buf to dst_frame */ - fil_decompress_page(slot->comp_buf, - dst_frame, - ulong(size), - &bpage->write_size); - ut_d(fil_page_type_validate(dst_frame)); - } - - /* Mark this slot as free */ - if (slot) { - slot->reserved = false; - } - } - - ut_ad(space->n_pending_ios > 0); - return (success); -} #endif /* !UNIV_INNOCHECKSUM */ diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 70422671190e49ac3561b722fc33a4c317071052..5f126ebb2a930ae01d0303711b980e892913780c 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -510,10 +510,11 @@ buf_dblwr_process() "Restoring possible half-written data pages " "from the doublewrite buffer..."); - unaligned_read_buf = static_cast(ut_malloc(2 * UNIV_PAGE_SIZE)); + unaligned_read_buf = static_cast(ut_malloc(3 * UNIV_PAGE_SIZE)); read_buf = static_cast( ut_align(unaligned_read_buf, UNIV_PAGE_SIZE)); + byte* const buf = read_buf + UNIV_PAGE_SIZE; for (std::list::iterator i = recv_dblwr.pages.begin(); i != recv_dblwr.pages.end(); ++i, ++page_no_dblwr ) { @@ -562,24 +563,23 @@ buf_dblwr_process() ignore this page (there should be redo log records to initialize it). */ } else { - if (fil_page_is_compressed_encrypted(read_buf) || - fil_page_is_compressed(read_buf)) { - /* Decompress the page before - validating the checksum. */ - fil_decompress_page( - NULL, read_buf, srv_page_size, - NULL, true); + /* Decompress the page before + validating the checksum. */ + ulint decomp = fil_page_decompress(buf, read_buf); + if (!decomp || (decomp != srv_page_size && zip_size)) { + goto bad; } if (fil_space_verify_crypt_checksum( - read_buf, zip_size, NULL, page_no) - || !buf_page_is_corrupted( - true, read_buf, zip_size, space())) { + read_buf, zip_size, NULL, page_no) + || !buf_page_is_corrupted( + true, read_buf, zip_size, space())) { /* The page is good; there is no need to consult the doublewrite buffer. */ continue; } +bad: /* We intentionally skip this message for is_all_zero pages. */ ib_logf(IB_LOG_LEVEL_INFO, @@ -588,18 +588,15 @@ buf_dblwr_process() space_id, page_no); } - /* Next, validate the doublewrite page. */ - if (fil_page_is_compressed_encrypted(page) || - fil_page_is_compressed(page)) { - /* Decompress the page before - validating the checksum. */ - fil_decompress_page( - NULL, page, srv_page_size, NULL, true); + ulint decomp = fil_page_decompress(buf, page); + if (!decomp || (decomp != srv_page_size && zip_size)) { + goto bad_doublewrite; } - - if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, page_no) + if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, + page_no) && buf_page_is_corrupted(true, page, zip_size, space)) { if (!is_all_zero) { +bad_doublewrite: ib_logf(IB_LOG_LEVEL_WARN, "A doublewrite copy of page " ULINTPF ":" ULINTPF " is corrupted.", diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 793d6cdd68eacde2d5ebfb5dca7904b7c6e957fb..7d9dbc74951e265a0a33b2409d2bd914ad3785e0 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -42,6 +42,7 @@ Created April 08, 2011 Vasil Dimov #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ #include "mysql/service_wsrep.h" /* wsrep_recovery */ +#include enum status_severity { STATUS_INFO, @@ -216,7 +217,20 @@ buf_dump( buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s", full_filename); - f = fopen(tmp_filename, "w"); +#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0 + f = fopen(tmp_filename, "w" STR_O_CLOEXEC); +#else + { + int fd; + fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640); + if (fd >= 0) { + f = fdopen(fd, "w"); + } + else { + f = NULL; + } + } +#endif if (f == NULL) { buf_dump_status(STATUS_ERR, "Cannot open '%s' for writing: %s", @@ -320,6 +334,14 @@ buf_dump( i + 1, srv_buf_pool_instances, j + 1, n_pages); } + if ( (j % 1024) == 0) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Dumping buffer pool " + ULINTPF "/" ULINTPF ", " + "page " ULINTPF "/" ULINTPF, + i + 1, srv_buf_pool_instances, + j + 1, n_pages); + } } ut_free(dump); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index dacddfca385f0bc266bfefe96e6340975af5d944..66704ac1344a9a881e17ee2ff8c7b71a1f73f421 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -54,6 +54,8 @@ Created 11/11/1995 Heikki Tuuri #include "mysql/service_thd_wait.h" #include "fil0pagecompress.h" +#include + /** Number of pages flushed through non flush_list flushes. */ static ulint buf_lru_flush_page_count = 0; @@ -528,6 +530,17 @@ buf_flush_remove( buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ulint zip_size; +#if 0 // FIXME: Rate-limit the output. Move this to the page cleaner? + if (UNIV_UNLIKELY(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE)) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "Flush and remove page with tablespace id %u" + ", Poolid " ULINTPF ", flush list length " ULINTPF, + bpage->space, buf_pool->instance_no, + UT_LIST_GET_LEN(buf_pool->flush_list)); + } +#endif + ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(bpage->in_flush_list); diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 9e89a291c80082a415b6baaa6b6fd0f0e6123b41..7039ecdf4a64bc4313bc9e5db2541e06eb60c389 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -241,8 +241,6 @@ void buf_LRU_drop_page_hash_batch( /*=========================*/ ulint space_id, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ const ulint* arr, /*!< in: array of page_no */ ulint count) /*!< in: number of entries in array */ { @@ -252,8 +250,7 @@ buf_LRU_drop_page_hash_batch( ut_ad(count <= BUF_LRU_DROP_SEARCH_SIZE); for (i = 0; i < count; ++i) { - btr_search_drop_page_hash_when_freed(space_id, zip_size, - arr[i]); + btr_search_drop_page_hash_when_freed(space_id, arr[i]); } } @@ -272,15 +269,6 @@ buf_LRU_drop_page_hash_for_tablespace( buf_page_t* bpage; ulint* page_arr; ulint num_entries; - ulint zip_size; - - zip_size = fil_space_get_zip_size(id); - - if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { - /* Somehow, the tablespace does not exist. Nothing to drop. */ - ut_ad(0); - return; - } page_arr = static_cast(ut_malloc( sizeof(ulint) * BUF_LRU_DROP_SEARCH_SIZE)); @@ -333,8 +321,7 @@ buf_LRU_drop_page_hash_for_tablespace( the latching order. */ buf_pool_mutex_exit(buf_pool); - buf_LRU_drop_page_hash_batch( - id, zip_size, page_arr, num_entries); + buf_LRU_drop_page_hash_batch(id, page_arr, num_entries); num_entries = 0; @@ -365,10 +352,32 @@ buf_LRU_drop_page_hash_for_tablespace( buf_pool_mutex_exit(buf_pool); /* Drop any remaining batch of search hashed pages. */ - buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries); + buf_LRU_drop_page_hash_batch(id, page_arr, num_entries); ut_free(page_arr); } +/** Drop the adaptive hash index for a tablespace. +@param[in,out] table table */ +UNIV_INTERN void buf_LRU_drop_page_hash_for_tablespace(dict_table_t* table) +{ + for (dict_index_t* index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + if (btr_search_info_get_ref_count( + btr_search_get_info(index))) { + goto drop_ahi; + } + } + + return; +drop_ahi: + ulint id = table->space; + for (ulint i = 0; i < srv_buf_pool_instances; i++) { + buf_LRU_drop_page_hash_for_tablespace(buf_pool_from_array(i), + id); + } +} + /******************************************************************//** While flushing (or removing dirty) pages from a tablespace we don't want to hog the CPU and resources. Release the buffer pool and block @@ -675,18 +684,11 @@ buf_flush_dirty_pages(buf_pool_t* buf_pool, ulint id, const trx_t* trx) /** Empty the flush list for all pages belonging to a tablespace. @param[in] id tablespace identifier @param[in] trx transaction, for checking for user interrupt; - or NULL if nothing is to be written -@param[in] drop_ahi whether to drop the adaptive hash index */ -UNIV_INTERN -void -buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx, bool drop_ahi) + or NULL if nothing is to be written */ +UNIV_INTERN void buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_t* buf_pool = buf_pool_from_array(i); - if (drop_ahi) { - buf_LRU_drop_page_hash_for_tablespace(buf_pool, id); - } - buf_flush_dirty_pages(buf_pool, id, trx); + buf_flush_dirty_pages(buf_pool_from_array(i), id, trx); } if (trx && !trx_is_interrupted(trx)) { diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index a2f79a400e2663ff506a9005136a658fa171424d..057e2684eb87b5e1a3e01062c8971080cd162b3e 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, 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 @@ -326,10 +327,8 @@ dict_build_table_def_step( mtr_commit(&mtr); } else { - /* Create in the system tablespace: disallow Barracuda - features by keeping only the first bit which says whether - the row format is redundant or compact */ - table->flags &= DICT_TF_COMPACT; + /* Create in the system tablespace */ + ut_ad(table->space == TRX_SYS_SPACE); } row = dict_create_sys_tables_tuple(table, node->heap); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 7ec4364becc24046e82a9f67c924202203c63e49..9609ef9634397db6e14aacf9c55bee084d0b7a3c 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -2,7 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -507,7 +507,8 @@ dict_table_try_drop_aborted( ut_ad(table->id == table_id); } - if (table && table->n_ref_count == ref_count && table->drop_aborted) { + if (table && table->n_ref_count == ref_count && table->drop_aborted + && !UT_LIST_GET_FIRST(table->locks)) { /* Silence a debug assertion in row_merge_drop_indexes(). */ ut_d(table->n_ref_count++); row_merge_drop_indexes(trx, table, TRUE); @@ -1673,7 +1674,7 @@ dict_table_rename_in_cache( filepath = fil_make_ibd_name(table->name, false); } - fil_delete_tablespace(table->space, true); + fil_delete_tablespace(table->space); /* Delete any temp file hanging around. */ if (os_file_status(filepath, &exists, &ftype) @@ -2718,35 +2719,13 @@ dict_index_remove_from_cache_low( zero. See also: dict_table_can_be_evicted() */ do { - ulint ref_count = btr_search_info_get_ref_count(info); - - if (ref_count == 0) { + if (!btr_search_info_get_ref_count(info)) { break; } - /* Sleep for 10ms before trying again. */ - os_thread_sleep(10000); - ++retries; - - if (retries % 500 == 0) { - /* No luck after 5 seconds of wait. */ - fprintf(stderr, "InnoDB: Error: Waited for" - " %lu secs for hash index" - " ref_count (%lu) to drop" - " to 0.\n" - "index: \"%s\"" - " table: \"%s\"\n", - retries/100, - ref_count, - index->name, - table->name); - } + buf_LRU_drop_page_hash_for_tablespace(table); - /* To avoid a hang here we commit suicide if the - ref_count doesn't drop to zero in 600 seconds. */ - if (retries >= 60000) { - ut_error; - } + ut_a(++retries < 10000); } while (srv_shutdown_state == SRV_SHUTDOWN_NONE || !lru_evict); rw_lock_free(&index->lock); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 4a2b6d43bbde080053f726220b91634d802c670c..b2065c7c4649ce07ebfd3c21f4c3bf56bd0e3699 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2018, 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 @@ -2067,10 +2067,12 @@ dict_load_table_low( ulint flags2; if (rec_get_deleted_flag(rec, 0)) { + *table = NULL; return("delete-marked record in SYS_TABLES"); } if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_TABLES) { + *table = NULL; return("wrong number of columns in SYS_TABLES record"); } @@ -2078,6 +2080,7 @@ dict_load_table_low( rec, DICT_FLD__SYS_TABLES__NAME, &len); if (len == 0 || len == UNIV_SQL_NULL) { err_len: + *table = NULL; return("incorrect column length in SYS_TABLES"); } rec_get_nth_field_offs_old( @@ -2157,6 +2160,7 @@ dict_load_table_low( "InnoDB: in InnoDB data dictionary" " has unknown type %lx.\n", (ulong) flags); + *table = NULL; return("incorrect flags in SYS_TABLES"); } diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 3095503cfc5569a81528249c9c024f2503b4d68d..932d7b9e31209988f3943aaca7d74c25d1bcfce4 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1,6 +1,6 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2014, 2018, MariaDB Corporation. All Rights Reserved. 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 @@ -114,17 +114,17 @@ extern my_bool srv_background_scrub_data_compressed; /*********************************************************************** Check if a key needs rotation given a key_state -@param[in] encrypt_mode Encryption mode +@param[in] crypt_data Encryption information @param[in] key_version Current key version @param[in] latest_key_version Latest key version @param[in] rotate_key_age when to rotate @return true if key needs rotation, false if not */ static bool fil_crypt_needs_rotation( - fil_encryption_t encrypt_mode, - uint key_version, - uint latest_key_version, - uint rotate_key_age) + const fil_space_crypt_t* crypt_data, + uint key_version, + uint latest_key_version, + uint rotate_key_age) MY_ATTRIBUTE((warn_unused_result)); /********************************************************************* @@ -187,7 +187,8 @@ fil_crypt_get_latest_key_version( if (crypt_data->is_key_found()) { - if (fil_crypt_needs_rotation(crypt_data->encryption, + if (fil_crypt_needs_rotation( + crypt_data, crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { @@ -707,60 +708,39 @@ fil_space_encrypt( #ifdef UNIV_DEBUG if (tmp) { /* Verify that encrypted buffer is not corrupted */ - byte* tmp_mem = (byte *)malloc(UNIV_PAGE_SIZE); dberr_t err = DB_SUCCESS; byte* src = src_frame; bool page_compressed_encrypted = (mach_read_from_2(tmp+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); - byte* comp_mem = NULL; - byte* uncomp_mem = NULL; + byte uncomp_mem[UNIV_PAGE_SIZE_MAX]; + byte tmp_mem[UNIV_PAGE_SIZE_MAX]; ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; if (page_compressed_encrypted) { - comp_mem = (byte *)malloc(UNIV_PAGE_SIZE); - uncomp_mem = (byte *)malloc(UNIV_PAGE_SIZE); - memcpy(comp_mem, src_frame, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_mem, comp_mem, - srv_page_size, NULL); - src = uncomp_mem; + memcpy(uncomp_mem, src, srv_page_size); + ulint unzipped1 = fil_page_decompress( + tmp_mem, uncomp_mem); + ut_ad(unzipped1); + if (unzipped1 != srv_page_size) { + src = uncomp_mem; + } } - bool corrupted1 = buf_page_is_corrupted(true, src, zip_size, space); - bool ok = fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err); + ut_ad(!buf_page_is_corrupted(true, src, zip_size, space)); + ut_ad(fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err)); + ut_ad(err == DB_SUCCESS); /* Need to decompress the page if it was also compressed */ if (page_compressed_encrypted) { - memcpy(comp_mem, tmp_mem, UNIV_PAGE_SIZE); - fil_decompress_page(tmp_mem, comp_mem, - srv_page_size, NULL); - } - - bool corrupted = buf_page_is_corrupted(true, tmp_mem, zip_size, space); - memcpy(tmp_mem+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, src+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8); - bool different = memcmp(src, tmp_mem, size); - - if (!ok || corrupted || corrupted1 || err != DB_SUCCESS || different) { - fprintf(stderr, "ok %d corrupted %d corrupted1 %d err %d different %d\n", - ok , corrupted, corrupted1, err, different); - fprintf(stderr, "src_frame\n"); - buf_page_print(src_frame, zip_size); - fprintf(stderr, "encrypted_frame\n"); - buf_page_print(tmp, zip_size); - fprintf(stderr, "decrypted_frame\n"); - buf_page_print(tmp_mem, zip_size); - ut_ad(0); - } - - free(tmp_mem); - - if (comp_mem) { - free(comp_mem); + byte buf[UNIV_PAGE_SIZE_MAX]; + memcpy(buf, tmp_mem, srv_page_size); + ulint unzipped2 = fil_page_decompress(tmp_mem, buf); + ut_ad(unzipped2); } - if (uncomp_mem) { - free(uncomp_mem); - } + memcpy(tmp_mem + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, + src + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8); + ut_ad(!memcmp(src, tmp_mem, size)); } - #endif /* UNIV_DEBUG */ return tmp; @@ -963,17 +943,17 @@ fil_crypt_get_key_state( /*********************************************************************** Check if a key needs rotation given a key_state -@param[in] encrypt_mode Encryption mode +@param[in] crypt_data Encryption information @param[in] key_version Current key version @param[in] latest_key_version Latest key version @param[in] rotate_key_age when to rotate @return true if key needs rotation, false if not */ static bool fil_crypt_needs_rotation( - fil_encryption_t encrypt_mode, - uint key_version, - uint latest_key_version, - uint rotate_key_age) + const fil_space_crypt_t* crypt_data, + uint key_version, + uint latest_key_version, + uint rotate_key_age) { if (key_version == ENCRYPTION_KEY_VERSION_INVALID) { return false; @@ -986,13 +966,20 @@ fil_crypt_needs_rotation( } if (latest_key_version == 0 && key_version != 0) { - if (encrypt_mode == FIL_ENCRYPTION_DEFAULT) { + if (crypt_data->encryption == FIL_ENCRYPTION_DEFAULT) { /* this is rotation encrypted => unencrypted */ return true; } return false; } + if (crypt_data->encryption == FIL_ENCRYPTION_DEFAULT + && crypt_data->type == CRYPT_SCHEME_1 + && srv_encrypt_tables == 0 ) { + /* This is rotation encrypted => unencrypted */ + return true; + } + /* this is rotation encrypted => encrypted, * only reencrypt if key is sufficiently old */ if (key_version + rotate_key_age < latest_key_version) { @@ -1008,10 +995,17 @@ static inline void fil_crypt_read_crypt_data(fil_space_t* space) { - if (space->crypt_data || space->size) { + if (space->crypt_data || space->size + || !fil_space_get_size(space->id)) { /* The encryption metadata has already been read, or the tablespace is not encrypted and the file has been - opened already. */ + opened already, or the file cannot be accessed, + likely due to a concurrent TRUNCATE or + RENAME or DROP (possibly as part of ALTER TABLE). + FIXME: The file can become unaccessible any time + after this check! We should really remove this + function and instead make crypt_data an integral + part of fil_space_t. */ return; } @@ -1272,9 +1266,10 @@ fil_crypt_space_needs_rotation( } bool need_key_rotation = fil_crypt_needs_rotation( - crypt_data->encryption, + crypt_data, crypt_data->min_key_version, - key_state->key_version, key_state->rotate_key_age); + key_state->key_version, + key_state->rotate_key_age); crypt_data->rotate_state.scrubbing.is_active = btr_scrub_start_space(space->id, &state->scrub_data); @@ -1862,9 +1857,10 @@ fil_crypt_rotate_page( ut_ad(kv == 0); ut_ad(page_get_space_id(frame) == 0); } else if (fil_crypt_needs_rotation( - crypt_data->encryption, - kv, key_state->key_version, - key_state->rotate_key_age)) { + crypt_data, + kv, + key_state->key_version, + key_state->rotate_key_age)) { modified = true; @@ -2002,6 +1998,12 @@ fil_crypt_rotate_pages( continue; } + /* If space is marked as stopping, stop rotating + pages. */ + if (state->space->is_stopping()) { + break; + } + fil_crypt_rotate_page(key_state, state); } } @@ -2050,20 +2052,22 @@ fil_crypt_flush_space( crypt_data->type = CRYPT_SCHEME_UNENCRYPTED; } - /* update page 0 */ - mtr_t mtr; - mtr_start(&mtr); + if (!space->is_stopping()) { + /* update page 0 */ + mtr_t mtr; + mtr_start(&mtr); - const uint zip_size = fsp_flags_get_zip_size(state->space->flags); + const uint zip_size = fsp_flags_get_zip_size(state->space->flags); - buf_block_t* block = buf_page_get_gen(space->id, zip_size, 0, + buf_block_t* block = buf_page_get_gen(space->id, zip_size, 0, RW_X_LATCH, NULL, BUF_GET, __FILE__, __LINE__, &mtr); - byte* frame = buf_block_get_frame(block); + byte* frame = buf_block_get_frame(block); - crypt_data->write_page0(frame, &mtr); + crypt_data->write_page0(frame, &mtr); - mtr_commit(&mtr); + mtr_commit(&mtr); + } } /*********************************************************************** diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index b4102e48628c63a07bb655ded614a4c380b3971d..5891db627586103c0af5765b31a2165889b84cdf 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -25,8 +25,6 @@ Created 10/25/1995 Heikki Tuuri *******************************************************/ #include "fil0fil.h" -#include "fil0pagecompress.h" -#include "fsp0pagecompress.h" #include "fil0crypt.h" #include @@ -49,12 +47,10 @@ Created 10/25/1995 Heikki Tuuri #include "page0zip.h" #include "trx0sys.h" #include "row0mysql.h" -#include "os0file.h" #ifndef UNIV_HOTBACKUP # include "buf0lru.h" # include "ibuf0ibuf.h" # include "sync0sync.h" -# include "os0sync.h" #else /* !UNIV_HOTBACKUP */ # include "srv0srv.h" static ulint srv_data_read, srv_data_written; @@ -346,19 +342,6 @@ fil_space_get_by_id( return(space); } -/****************************************************************//** -Get space id from fil node */ -ulint -fil_node_get_space_id( -/*==================*/ - fil_node_t* node) /*!< in: Compressed node*/ -{ - ut_ad(node); - ut_ad(node->space); - - return (node->space->id); -} - /*******************************************************************//** Returns the table space by a given name, NULL if not found. */ UNIV_INLINE @@ -696,7 +679,7 @@ fil_node_open_file( space->size += node->size; } - ulint atomic_writes = fsp_flags_get_atomic_writes(space->flags); + ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(space->flags); /* printf("Opening file %s\n", node->name); */ @@ -1096,7 +1079,6 @@ fil_mutex_enter_and_prepare_for_io( { fil_space_t* space; ulint count = 0; - ulint count2 = 0; retry: mutex_enter(&fil_system->mutex); @@ -1112,47 +1094,6 @@ fil_mutex_enter_and_prepare_for_io( return; } - if (space->stop_ios) { - ut_ad(space->id != 0); - /* We are going to do a rename file and want to stop new i/o's - for a while */ - - if (count2 > 20000) { - fputs("InnoDB: Warning: tablespace ", stderr); - ut_print_filename(stderr, space->name); - fprintf(stderr, - " has i/o ops stopped for a long time %lu\n", - (ulong) count2); - } - - mutex_exit(&fil_system->mutex); - -#ifndef UNIV_HOTBACKUP - - /* Wake the i/o-handler threads to make sure pending - i/o's are performed */ - os_aio_simulated_wake_handler_threads(); - - /* The sleep here is just to give IO helper threads a - bit of time to do some work. It is not required that - all IO related to the tablespace being renamed must - be flushed here as we do fil_flush() in - fil_rename_tablespace() as well. */ - os_thread_sleep(20000); - -#endif /* UNIV_HOTBACKUP */ - - /* Flush tablespaces so that we can close modified - files in the LRU list */ - fil_flush_file_spaces(FIL_TABLESPACE); - - os_thread_sleep(20000); - - count2++; - - goto retry; - } - fil_node_t* node = UT_LIST_GET_LAST(space->chain); ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain)); @@ -2895,7 +2836,7 @@ fil_delete_tablespace(ulint id, bool drop_ahi) To deal with potential read requests by checking the ::stop_new_ops flag in fil_io() */ - buf_LRU_flush_or_remove_pages(id, NULL, drop_ahi); + buf_LRU_flush_or_remove_pages(id, NULL); #endif /* !UNIV_HOTBACKUP */ @@ -3006,7 +2947,7 @@ fil_discard_tablespace( { dberr_t err; - switch (err = fil_delete_tablespace(id, true)) { + switch (err = fil_delete_tablespace(id)) { case DB_SUCCESS: break; @@ -3208,7 +3149,6 @@ fil_rename_tablespace( ibool success; fil_space_t* space; fil_node_t* node; - ulint count = 0; char* new_path; char* old_name; char* old_path; @@ -3216,25 +3156,10 @@ fil_rename_tablespace( ut_a(id != 0); -retry: - count++; - - if (!(count % 1000)) { - ut_print_timestamp(stderr); - fputs(" InnoDB: Warning: problems renaming ", stderr); - ut_print_filename(stderr, - old_name_in ? old_name_in : not_given); - fputs(" to ", stderr); - ut_print_filename(stderr, new_name); - fprintf(stderr, ", %lu iterations\n", (ulong) count); - } - mutex_enter(&fil_system->mutex); space = fil_space_get_by_id(id); - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; ); - if (space == NULL) { ib_logf(IB_LOG_LEVEL_ERROR, "Cannot find space id %lu in the tablespace " @@ -3246,54 +3171,11 @@ fil_rename_tablespace( return(FALSE); } - if (count > 25000) { - space->stop_ios = FALSE; - mutex_exit(&fil_system->mutex); - - return(FALSE); - } - - /* We temporarily close the .ibd file because we do not trust that - operating systems can rename an open file. For the closing we have to - wait until there are no pending i/o's or flushes on the file. */ - - space->stop_ios = TRUE; - /* The following code must change when InnoDB supports multiple datafiles per tablespace. */ ut_a(UT_LIST_GET_LEN(space->chain) == 1); node = UT_LIST_GET_FIRST(space->chain); - if (node->n_pending > 0 - || node->n_pending_flushes > 0 - || node->being_extended) { - /* There are pending i/o's or flushes or the file is - currently being extended, sleep for a while and - retry */ - - mutex_exit(&fil_system->mutex); - - os_thread_sleep(20000); - - goto retry; - - } else if (node->modification_counter > node->flush_counter) { - /* Flush the space */ - - mutex_exit(&fil_system->mutex); - - os_thread_sleep(20000); - - fil_flush(id); - - goto retry; - - } else if (node->open) { - /* Close the file */ - - fil_node_close_file(node, fil_system); - } - /* Check that the old name in the space is right */ if (old_name_in) { @@ -3312,17 +3194,9 @@ fil_rename_tablespace( space, node, new_name, new_path); if (success) { - - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", - goto skip_second_rename; ); - success = os_file_rename( innodb_file_data_key, old_path, new_path); - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", -skip_second_rename: - success = FALSE; ); - if (!success) { /* We have to revert the changes we made to the tablespace memory cache */ @@ -3332,8 +3206,6 @@ fil_rename_tablespace( } } - space->stop_ios = FALSE; - mutex_exit(&fil_system->mutex); #ifndef UNIV_HOTBACKUP @@ -3921,7 +3793,6 @@ fil_open_single_table_tablespace( fsp_open_info remote; ulint tablespaces_found = 0; ulint valid_tablespaces_found = 0; - ulint atomic_writes = 0; fil_space_crypt_t* crypt_data = NULL; #ifdef UNIV_SYNC_DEBUG @@ -3936,7 +3807,7 @@ fil_open_single_table_tablespace( } ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, id)); - atomic_writes = fsp_flags_get_atomic_writes(flags); + const ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(flags); memset(&def, 0, sizeof(def)); memset(&dict, 0, sizeof(dict)); @@ -4278,17 +4149,7 @@ fil_open_single_table_tablespace( mem_free(def.filepath); - /* We need to check fsp flags when no errors has happened and - server was not started on read only mode and tablespace validation - was requested or flags contain other table options except - low order bits to FSP_FLAGS_POS_PAGE_SSIZE position. - Note that flag comparison is pessimistic. Adjust is required - only when flags contain buggy MariaDB 10.1.0 - - MariaDB 10.1.20 flags. */ - if (err == DB_SUCCESS - && !srv_read_only_mode - && (validate - || flags >= (1U << FSP_FLAGS_POS_PAGE_SSIZE))) { + if (err == DB_SUCCESS && validate && !srv_read_only_mode) { fsp_flags_try_adjust(id, flags & ~FSP_FLAGS_MEM_MASK); } @@ -5851,7 +5712,8 @@ fil_io( } else if (type == OS_FILE_WRITE) { ut_ad(!srv_read_only_mode); srv_stats.data_written.add(len); - if (fil_page_is_index_page((byte *)buf)) { + if (mach_read_from_2(static_cast(buf) + + FIL_PAGE_TYPE) == FIL_PAGE_INDEX) { srv_stats.index_pages_written.inc(); } else { srv_stats.non_index_pages_written.inc(); @@ -6348,479 +6210,6 @@ fil_close(void) fil_system = NULL; } -/********************************************************************//** -Initializes a buffer control block when the buf_pool is created. */ -static -void -fil_buf_block_init( -/*===============*/ - buf_block_t* block, /*!< in: pointer to control block */ - byte* frame) /*!< in: pointer to buffer frame */ -{ - UNIV_MEM_DESC(frame, UNIV_PAGE_SIZE); - - block->frame = frame; - - block->page.io_fix = BUF_IO_NONE; - /* There are assertions that check for this. */ - block->page.buf_fix_count = 1; - block->page.state = BUF_BLOCK_READY_FOR_USE; - - page_zip_des_init(&block->page.zip); -} - -struct fil_iterator_t { - pfs_os_file_t file; /*!< File handle */ - const char* filepath; /*!< File path name */ - os_offset_t start; /*!< From where to start */ - os_offset_t end; /*!< Where to stop */ - os_offset_t file_size; /*!< File size in bytes */ - ulint page_size; /*!< Page size */ - ulint n_io_buffers; /*!< Number of pages to use - for IO */ - byte* io_buffer; /*!< Buffer to use for IO */ - fil_space_crypt_t *crypt_data; /*!< Crypt data (if encrypted) */ - byte* crypt_io_buffer; /*!< IO buffer when encrypted */ -}; - -/********************************************************************//** -TODO: This can be made parallel trivially by chunking up the file and creating -a callback per thread. . Main benefit will be to use multiple CPUs for -checksums and compressed tables. We have to do compressed tables block by -block right now. Secondly we need to decompress/compress and copy too much -of data. These are CPU intensive. - -Iterate over all the pages in the tablespace. -@param iter - Tablespace iterator -@param block - block to use for IO -@param callback - Callback to inspect and update page contents -@retval DB_SUCCESS or error code */ -static -dberr_t -fil_iterate( -/*========*/ - const fil_iterator_t& iter, - buf_block_t* block, - PageCallback& callback) -{ - os_offset_t offset; - ulint page_no = 0; - ulint space_id = callback.get_space_id(); - ulint n_bytes = iter.n_io_buffers * iter.page_size; - - ut_ad(!srv_read_only_mode); - - /* TODO: For compressed tables we do a lot of useless - copying for non-index pages. Unfortunately, it is - required by buf_zip_decompress() */ - const bool row_compressed = callback.get_zip_size() > 0; - - for (offset = iter.start; offset < iter.end; offset += n_bytes) { - - byte* io_buffer = iter.io_buffer; - - block->frame = io_buffer; - - if (row_compressed) { - page_zip_des_init(&block->page.zip); - page_zip_set_size(&block->page.zip, iter.page_size); - block->page.zip.data = block->frame + UNIV_PAGE_SIZE; - ut_d(block->page.zip.m_external = true); - ut_ad(iter.page_size == callback.get_zip_size()); - - /* Zip IO is done in the compressed page buffer. */ - io_buffer = block->page.zip.data; - } - - /* We have to read the exact number of bytes. Otherwise the - InnoDB IO functions croak on failed reads. */ - - n_bytes = static_cast( - ut_min(static_cast(n_bytes), - iter.end - offset)); - - ut_ad(n_bytes > 0); - ut_ad(!(n_bytes % iter.page_size)); - - const bool encrypted = iter.crypt_data != NULL - && iter.crypt_data->should_encrypt(); - /* Use additional crypt io buffer if tablespace is encrypted */ - byte* const readptr = encrypted - ? iter.crypt_io_buffer : io_buffer; - byte* const writeptr = readptr; - - if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) { - - ib_logf(IB_LOG_LEVEL_ERROR, "os_file_read() failed"); - - return(DB_IO_ERROR); - } - - bool updated = false; - os_offset_t page_off = offset; - ulint n_pages_read = (ulint) n_bytes / iter.page_size; - bool decrypted = false; - - for (ulint i = 0; i < n_pages_read; ++i) { - ulint size = iter.page_size; - dberr_t err = DB_SUCCESS; - byte* src = readptr + (i * size); - byte* dst = io_buffer + (i * size); - bool frame_changed = false; - - ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); - - const bool page_compressed - = page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED - || page_type == FIL_PAGE_PAGE_COMPRESSED; - - /* If tablespace is encrypted, we need to decrypt - the page. Note that tablespaces are not in - fil_system during import. */ - if (encrypted) { - decrypted = fil_space_decrypt( - iter.crypt_data, - dst, //dst - iter.page_size, - src, // src - &err); // src - - if (err != DB_SUCCESS) { - return(err); - } - - if (decrypted) { - updated = true; - } else { - if (!page_compressed && !row_compressed) { - block->frame = src; - frame_changed = true; - } else { - memcpy(dst, src, size); - } - } - } - - /* If the original page is page_compressed, we need - to decompress page before we can update it. */ - if (page_compressed) { - fil_decompress_page(NULL, dst, ulong(size), - NULL); - updated = true; - } - - buf_block_set_file_page(block, space_id, page_no++); - - if ((err = callback(page_off, block)) != DB_SUCCESS) { - - return(err); - - } else if (!updated) { - updated = buf_block_get_state(block) - == BUF_BLOCK_FILE_PAGE; - } - - buf_block_set_state(block, BUF_BLOCK_NOT_USED); - buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); - - /* If tablespace is encrypted we use additional - temporary scratch area where pages are read - for decrypting readptr == crypt_io_buffer != io_buffer. - - Destination for decryption is a buffer pool block - block->frame == dst == io_buffer that is updated. - Pages that did not require decryption even when - tablespace is marked as encrypted are not copied - instead block->frame is set to src == readptr. - - For encryption we again use temporary scratch area - writeptr != io_buffer == dst - that is then written to the tablespace - - (1) For normal tables io_buffer == dst == writeptr - (2) For only page compressed tables - io_buffer == dst == writeptr - (3) For encrypted (and page compressed) - readptr != io_buffer == dst != writeptr - */ - - ut_ad(!encrypted && !page_compressed ? - src == dst && dst == writeptr + (i * size):1); - ut_ad(page_compressed && !encrypted ? - src == dst && dst == writeptr + (i * size):1); - ut_ad(encrypted ? - src != dst && dst != writeptr + (i * size):1); - - if (encrypted) { - memcpy(writeptr + (i * size), - row_compressed ? block->page.zip.data : - block->frame, size); - } - - if (frame_changed) { - block->frame = dst; - } - - src = io_buffer + (i * size); - - if (page_compressed) { - ulint len = 0; - - fil_compress_page( - NULL, - src, - NULL, - size, - 0,/* FIXME: compression level */ - 512,/* FIXME: use proper block size */ - encrypted, - &len); - - updated = true; - } - - /* If tablespace is encrypted, encrypt page before we - write it back. Note that we should not encrypt the - buffer that is in buffer pool. */ - /* NOTE: At this stage of IMPORT the - buffer pool is not being used at all! */ - if (decrypted && encrypted) { - byte *dest = writeptr + (i * size); - ulint space = mach_read_from_4( - src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - ulint offset = mach_read_from_4(src + FIL_PAGE_OFFSET); - ib_uint64_t lsn = mach_read_from_8(src + FIL_PAGE_LSN); - - byte* tmp = fil_encrypt_buf( - iter.crypt_data, - space, - offset, - lsn, - src, - iter.page_size == UNIV_PAGE_SIZE ? 0 : iter.page_size, - dest); - - if (tmp == src) { - /* TODO: remove unnecessary memcpy's */ - memcpy(dest, src, size); - } - - updated = true; - } - - page_off += iter.page_size; - block->frame += iter.page_size; - } - - /* A page was updated in the set, write back to disk. */ - if (updated - && !os_file_write( - iter.filepath, iter.file, writeptr, - offset, (ulint) n_bytes)) { - - ib_logf(IB_LOG_LEVEL_ERROR, "os_file_write() failed"); - - return(DB_IO_ERROR); - } - } - - return(DB_SUCCESS); -} - -/********************************************************************//** -Iterate over all the pages in the tablespace. -@param table - the table definiton in the server -@param n_io_buffers - number of blocks to read and write together -@param callback - functor that will do the page updates -@return DB_SUCCESS or error code */ -UNIV_INTERN -dberr_t -fil_tablespace_iterate( -/*===================*/ - dict_table_t* table, - ulint n_io_buffers, - PageCallback& callback) -{ - dberr_t err; - pfs_os_file_t file; - char* filepath; - - ut_a(n_io_buffers > 0); - ut_ad(!srv_read_only_mode); - - DBUG_EXECUTE_IF("ib_import_trigger_corruption_1", - return(DB_CORRUPTION);); - - if (DICT_TF_HAS_DATA_DIR(table->flags)) { - dict_get_and_save_data_dir_path(table, false); - ut_a(table->data_dir_path); - - filepath = os_file_make_remote_pathname( - table->data_dir_path, table->name, "ibd"); - } else { - filepath = fil_make_ibd_name(table->name, false); - } - - { - ibool success; - - file = os_file_create_simple_no_error_handling( - innodb_file_data_key, filepath, - OS_FILE_OPEN, OS_FILE_READ_WRITE, &success, FALSE); - - DBUG_EXECUTE_IF("fil_tablespace_iterate_failure", - { - static bool once; - - if (!once || ut_rnd_interval(0, 10) == 5) { - once = true; - success = FALSE; - os_file_close(file); - } - }); - - if (!success) { - /* The following call prints an error message */ - os_file_get_last_error(true); - - ib_logf(IB_LOG_LEVEL_ERROR, - "Trying to import a tablespace, but could not " - "open the tablespace file %s", filepath); - - mem_free(filepath); - - return(DB_TABLESPACE_NOT_FOUND); - - } else { - err = DB_SUCCESS; - } - } - - callback.set_file(filepath, file); - - os_offset_t file_size = os_file_get_size(file); - ut_a(file_size != (os_offset_t) -1); - - /* The block we will use for every physical page */ - buf_block_t block; - - memset(&block, 0x0, sizeof(block)); - - /* Allocate a page to read in the tablespace header, so that we - can determine the page size and zip_size (if it is compressed). - We allocate an extra page in case it is a compressed table. One - page is to ensure alignement. */ - - void* page_ptr = mem_alloc(3 * UNIV_PAGE_SIZE); - byte* page = static_cast(ut_align(page_ptr, UNIV_PAGE_SIZE)); - - fil_buf_block_init(&block, page); - - /* Read the first page and determine the page and zip size. */ - - if (!os_file_read(file, page, 0, UNIV_PAGE_SIZE)) { - - err = DB_IO_ERROR; - - } else if ((err = callback.init(file_size, &block)) == DB_SUCCESS) { - fil_iterator_t iter; - - iter.file = file; - iter.start = 0; - iter.end = file_size; - iter.filepath = filepath; - iter.file_size = file_size; - iter.n_io_buffers = n_io_buffers; - iter.page_size = callback.get_page_size(); - - /* In MariaDB/MySQL 5.6 tablespace does not exist - during import, therefore we can't use space directly - here. */ - ulint crypt_data_offset = fsp_header_get_crypt_offset( - callback.get_zip_size()); - - /* read (optional) crypt data */ - iter.crypt_data = fil_space_read_crypt_data( - 0, page, crypt_data_offset); - - /* Compressed pages can't be optimised for block IO for now. - We do the IMPORT page by page. */ - - if (callback.get_zip_size() > 0) { - iter.n_io_buffers = 1; - ut_a(iter.page_size == callback.get_zip_size()); - } - - /** If tablespace is encrypted, it needs extra buffers */ - if (iter.crypt_data != NULL) { - /* decrease io buffers so that memory - * consumption doesnt double - * note: the +1 is to avoid n_io_buffers getting down to 0 */ - iter.n_io_buffers = (iter.n_io_buffers + 1) / 2; - } - - /** Add an extra page for compressed page scratch area. */ - - void* io_buffer = mem_alloc( - (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); - - iter.io_buffer = static_cast( - ut_align(io_buffer, UNIV_PAGE_SIZE)); - - void* crypt_io_buffer = NULL; - if (iter.crypt_data != NULL) { - crypt_io_buffer = mem_alloc( - (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); - iter.crypt_io_buffer = static_cast( - ut_align(crypt_io_buffer, UNIV_PAGE_SIZE)); - } - - err = fil_iterate(iter, &block, callback); - - mem_free(io_buffer); - - if (crypt_io_buffer != NULL) { - mem_free(crypt_io_buffer); - iter.crypt_io_buffer = NULL; - fil_space_destroy_crypt_data(&iter.crypt_data); - } - } - - if (err == DB_SUCCESS) { - - ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk"); - - if (!os_file_flush(file)) { - ib_logf(IB_LOG_LEVEL_INFO, "os_file_flush() failed!"); - err = DB_IO_ERROR; - } else { - ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk - done!"); - } - } - - os_file_close(file); - - mem_free(page_ptr); - mem_free(filepath); - - return(err); -} - -/** -Set the tablespace compressed table size. -@return DB_SUCCESS if it is valie or DB_CORRUPTION if not */ -dberr_t -PageCallback::set_zip_size(const buf_frame_t* page) UNIV_NOTHROW -{ - m_zip_size = fsp_header_get_zip_size(page); - - if (!ut_is_2pow(m_zip_size) || m_zip_size > UNIV_ZIP_SIZE_MAX) { - return(DB_CORRUPTION); - } - - return(DB_SUCCESS); -} - /********************************************************************//** Delete the tablespace file and any related files like .cfg. This should not be called for temporary tables. */ diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index edc932f36f5f193d990e255fa1bb9e6639e6aeab..25cd8e28a91dd35006f703dc6d57d28cdbe752f4 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018, 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 @@ -80,73 +80,26 @@ static ulint srv_data_read, srv_data_written; #include "snappy-c.h" #endif -/* Used for debugging */ -//#define UNIV_PAGECOMPRESS_DEBUG 1 - -/****************************************************************//** -For page compressed pages compress the page before actual write -operation. -@return compressed page to be written*/ -UNIV_INTERN -byte* -fil_compress_page( -/*==============*/ - fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ - byte* buf, /*!< in: buffer from which to write; in aio - this must be appropriately aligned */ - byte* out_buf, /*!< out: compressed buffer */ - ulint len, /*!< in: length of input buffer.*/ - ulint level, /* in: compression level */ - ulint block_size, /*!< in: block size */ - bool encrypted, /*!< in: is page also encrypted */ - ulint* out_len) /*!< out: actual length of compressed - page */ +/** Compress a page_compressed page before writing to a data file. +@param[in] buf page to be compressed +@param[out] out_buf compressed page +@param[in] level compression level +@param[in] block_size file system block size +@param[in] encrypted whether the page will be subsequently encrypted +@return actual length of compressed page +@retval 0 if the page was not compressed */ +UNIV_INTERN ulint fil_page_compress(const byte* buf, byte* out_buf, ulint level, + ulint block_size, bool encrypted) { - int err = Z_OK; - int comp_level = level; + int comp_level = int(level); ulint header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; - ulint write_size = 0; -#if HAVE_LZO - lzo_uint write_size_lzo = write_size; -#endif /* Cache to avoid change during function execution */ ulint comp_method = innodb_compression_algorithm; - bool allocated = false; - - /* page_compression does not apply to tables or tablespaces - that use ROW_FORMAT=COMPRESSED */ - ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags)); if (encrypted) { header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; } - if (!out_buf) { - allocated = true; - ulint size = UNIV_PAGE_SIZE; - - /* Both snappy and lzo compression methods require that - output buffer used for compression is bigger than input - buffer. Increase the allocated buffer size accordingly. */ -#if HAVE_SNAPPY - if (comp_method == PAGE_SNAPPY_ALGORITHM) { - size = snappy_max_compressed_length(size); - } -#endif -#if HAVE_LZO - if (comp_method == PAGE_LZO_ALGORITHM) { - size += LZO1X_1_15_MEM_COMPRESS; - } -#endif - - out_buf = static_cast(ut_malloc(size)); - } - - ut_ad(buf); - ut_ad(out_buf); - ut_ad(len); - ut_ad(out_len); - /* Let's not compress file space header or extent descriptor */ switch (fil_page_get_type(buf)) { @@ -154,8 +107,7 @@ fil_compress_page( case FIL_PAGE_TYPE_FSP_HDR: case FIL_PAGE_TYPE_XDES: case FIL_PAGE_PAGE_COMPRESSED: - *out_len = len; - goto err_exit; + return 0; } /* If no compression level was provided to this table, use system @@ -164,204 +116,113 @@ fil_compress_page( comp_level = page_zip_level; } - DBUG_PRINT("compress", - ("Preparing for space " ULINTPF " '%s' len " ULINTPF, - space ? space->id : 0, - space ? space->name : "(import)", - len)); - - write_size = UNIV_PAGE_SIZE - header_len; + ulint write_size = srv_page_size - header_len; - switch(comp_method) { + switch (comp_method) { + default: + ut_ad(!"unknown compression method"); + /* fall through */ + case PAGE_UNCOMPRESSED: + return 0; + case PAGE_ZLIB_ALGORITHM: + { + ulong len = uLong(write_size); + if (Z_OK == compress2( + out_buf + header_len, &len, + buf, uLong(srv_page_size), comp_level)) { + write_size = len; + goto success; + } + } + break; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: - -#ifdef HAVE_LZ4_COMPRESS_DEFAULT - err = LZ4_compress_default((const char *)buf, - (char *)out_buf+header_len, len, write_size); -#else - err = LZ4_compress_limitedOutput((const char *)buf, - (char *)out_buf+header_len, len, write_size); -#endif /* HAVE_LZ4_COMPRESS_DEFAULT */ - write_size = err; - - if (err == 0) { - /* If error we leave the actual page as it was */ - -#ifndef UNIV_PAGECOMPRESS_DEBUG - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; -#endif - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); -#ifndef UNIV_PAGECOMPRESS_DEBUG - } -#endif - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; +# ifdef HAVE_LZ4_COMPRESS_DEFAULT + write_size = LZ4_compress_default( + reinterpret_cast(buf), + reinterpret_cast(out_buf) + header_len, + int(srv_page_size), int(write_size)); +# else + write_size = LZ4_compress_limitedOutput( + reinterpret_cast(buf), + reinterpret_cast(out_buf) + header_len, + int(srv_page_size), int(write_size)); +# endif + + if (write_size) { + goto success; } break; #endif /* HAVE_LZ4 */ #ifdef HAVE_LZO - case PAGE_LZO_ALGORITHM: - err = lzo1x_1_15_compress( - buf, len, out_buf+header_len, &write_size_lzo, out_buf+UNIV_PAGE_SIZE); - - write_size = write_size_lzo; - - if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + case PAGE_LZO_ALGORITHM: { + lzo_uint len = write_size; + + if (LZO_E_OK == lzo1x_1_15_compress( + buf, srv_page_size, + out_buf + header_len, &len, + out_buf + srv_page_size) + && len <= write_size) { + write_size = len; + goto success; } - break; + } #endif /* HAVE_LZO */ #ifdef HAVE_LZMA case PAGE_LZMA_ALGORITHM: { - size_t out_pos=0; - - err = lzma_easy_buffer_encode( - comp_level, - LZMA_CHECK_NONE, - NULL, /* No custom allocator, use malloc/free */ - reinterpret_cast(buf), - len, - reinterpret_cast(out_buf + header_len), - &out_pos, - (size_t)write_size); - - if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, out_pos); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + size_t out_pos = 0; + + if (LZMA_OK == lzma_easy_buffer_encode( + comp_level, LZMA_CHECK_NONE, NULL, + buf, srv_page_size, out_buf + header_len, + &out_pos, write_size) + && out_pos <= write_size) { + write_size = out_pos; + goto success; } - - write_size = out_pos; - break; } #endif /* HAVE_LZMA */ #ifdef HAVE_BZIP2 case PAGE_BZIP2_ALGORITHM: { - - err = BZ2_bzBuffToBuffCompress( - (char *)(out_buf + header_len), - (unsigned int *)&write_size, - (char *)buf, - len, - 1, - 0, - 0); - - if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + unsigned len = unsigned(write_size); + if (BZ_OK == BZ2_bzBuffToBuffCompress( + reinterpret_cast(out_buf + header_len), + &len, + const_cast( + reinterpret_cast(buf)), + unsigned(srv_page_size), 1, 0, 0) + && len <= write_size) { + write_size = len; + goto success; } break; } #endif /* HAVE_BZIP2 */ #ifdef HAVE_SNAPPY - case PAGE_SNAPPY_ALGORITHM: - { - snappy_status cstatus; - write_size = snappy_max_compressed_length(UNIV_PAGE_SIZE); - - cstatus = snappy_compress( - (const char *)buf, - (size_t)len, - (char *)(out_buf+header_len), - (size_t*)&write_size); - - if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - (int)cstatus, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + case PAGE_SNAPPY_ALGORITHM: { + size_t len = snappy_max_compressed_length(srv_page_size); + + if (SNAPPY_OK == snappy_compress( + reinterpret_cast(buf), + srv_page_size, + reinterpret_cast(out_buf) + header_len, + &len) + && len <= write_size) { + write_size = len; + goto success; } break; } #endif /* HAVE_SNAPPY */ - - case PAGE_ZLIB_ALGORITHM: - err = compress2(out_buf+header_len, (ulong*)&write_size, buf, - uLong(len), comp_level); - - if (err != Z_OK) { - /* If error we leave the actual page as it was */ - - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " rt %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; - } - break; - - case PAGE_UNCOMPRESSED: - *out_len = len; - return (buf); - break; - default: - ut_error; - break; } + srv_stats.pages_page_compression_error.inc(); + return 0; +success: /* Set up the page header */ memcpy(out_buf, buf, FIL_PAGE_DATA); /* Set up the checksum */ @@ -392,22 +253,11 @@ fil_compress_page( /* Verify that page can be decompressed */ { - byte *comp_page; - byte *uncomp_page; - - comp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - uncomp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - memcpy(comp_page, out_buf, UNIV_PAGE_SIZE); - - fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); - - if (buf_page_is_corrupted(false, uncomp_page, 0, space)) { - buf_page_print(uncomp_page, 0); - ut_ad(0); - } - - ut_free(comp_page); - ut_free(uncomp_page); + page_t tmp_buf[UNIV_PAGE_SIZE_MAX]; + page_t page[UNIV_PAGE_SIZE_MAX]; + memcpy(page, out_buf, srv_page_size); + ut_ad(fil_page_decompress(tmp_buf, page)); + ut_ad(!buf_page_is_corrupted(false, page, 0, NULL)); } #endif /* UNIV_DEBUG */ @@ -431,324 +281,144 @@ fil_compress_page( #endif } - DBUG_PRINT("compress", - ("Succeeded for space " ULINTPF - " '%s' len " ULINTPF " out_len " ULINTPF, - space ? space->id : 0, - space ? space->name : "(import)", - len, write_size)); - - srv_stats.page_compression_saved.add((len - write_size)); + srv_stats.page_compression_saved.add(srv_page_size - write_size); srv_stats.pages_page_compressed.inc(); /* If we do not persistently trim rest of page, we need to write it all */ if (!srv_use_trim) { - memset(out_buf+write_size,0,len-write_size); - write_size = len; - } - - *out_len = write_size; - - if (allocated) { - /* TODO: reduce number of memcpy's */ - memcpy(buf, out_buf, len); - } else { - return(out_buf); - } - -err_exit: - if (allocated) { - ut_free(out_buf); + memset(out_buf + write_size, 0, srv_page_size - write_size); } - return (buf); - + return write_size; } -/****************************************************************//** -For page compressed pages decompress the page after actual read -operation. */ -UNIV_INTERN -void -fil_decompress_page( -/*================*/ - byte* page_buf, /*!< in: preallocated buffer or NULL */ - byte* buf, /*!< out: buffer from which to read; in aio - this must be appropriately aligned */ - ulong len, /*!< in: length of output buffer.*/ - ulint* write_size, /*!< in/out: Actual payload size of - the compressed data. */ - bool return_error) /*!< in: true if only an error should - be produced when decompression fails. - By default this parameter is false. */ +/** Decompress a page that may be subject to page_compressed compression. +@param[in,out] tmp_buf temporary buffer (of innodb_page_size) +@param[in,out] buf possibly compressed page buffer +@return size of the compressed data +@retval 0 if decompression failed +@retval srv_page_size if the page was not compressed */ +UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) { - int err = 0; - ulint actual_size = 0; - ulint compression_alg = 0; - byte *in_buf; - ulint ptype; - ulint header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; - - ut_ad(buf); - ut_ad(len); - - ptype = mach_read_from_2(buf+FIL_PAGE_TYPE); - - if (ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { - header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; - } - - /* Do not try to uncompressed pages that are not compressed */ - if (ptype != FIL_PAGE_PAGE_COMPRESSED && - ptype != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED && - ptype != FIL_PAGE_TYPE_COMPRESSED) { - return; - } - - // If no buffer was given, we need to allocate temporal buffer - if (page_buf == NULL) { - in_buf = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - memset(in_buf, 0, UNIV_PAGE_SIZE); - } else { - in_buf = page_buf; + const unsigned ptype = mach_read_from_2(buf+FIL_PAGE_TYPE); + ulint header_len; + ib_uint64_t compression_alg; + switch (ptype) { + case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED: + header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE + + FIL_PAGE_COMPRESSION_METHOD_SIZE; + compression_alg = mach_read_from_2( + FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE + buf); + break; + case FIL_PAGE_PAGE_COMPRESSED: + header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; + compression_alg = mach_read_from_8( + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + buf); + break; + default: + return srv_page_size; } - /* Before actual decompress, make sure that page type is correct */ - - if (mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM) != BUF_NO_CHECKSUM_MAGIC || - (ptype != FIL_PAGE_PAGE_COMPRESSED && - ptype != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: We try to uncompress corrupted page" - " CRC " ULINTPF " type " ULINTPF " len " ULINTPF ".", - mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM), - mach_read_from_2(buf+FIL_PAGE_TYPE), len); - - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; + if (mach_read_from_4(buf + FIL_PAGE_SPACE_OR_CHKSUM) + != BUF_NO_CHECKSUM_MAGIC) { + return 0; } - /* Get compression algorithm */ - if (ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { - compression_alg = mach_read_from_2(buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE); - } else { - compression_alg = mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - } + ulint actual_size = mach_read_from_2(buf + FIL_PAGE_DATA); - /* Get the actual size of compressed page */ - actual_size = mach_read_from_2(buf+FIL_PAGE_DATA); /* Check if payload size is corrupted */ - if (actual_size == 0 || actual_size > UNIV_PAGE_SIZE) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: We try to uncompress corrupted page" - " actual size " ULINTPF " compression %s.", - actual_size, fil_get_compression_alg_name(compression_alg)); - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; + if (actual_size == 0 || actual_size > srv_page_size - header_len) { + return 0; } - /* Store actual payload size of the compressed data. This pointer - points to buffer pool. */ - if (write_size) { - *write_size = actual_size; - } - - DBUG_PRINT("compress", - ("Preparing for decompress for len " ULINTPF ".", - actual_size)); - - switch(compression_alg) { + switch (compression_alg) { + default: + ib_logf(IB_LOG_LEVEL_ERROR, + "Unknown compression algorithm " UINT64PF, + compression_alg); + return 0; case PAGE_ZLIB_ALGORITHM: - err= uncompress(in_buf, &len, buf+header_len, (unsigned long)actual_size); - - /* If uncompress fails it means that page is corrupted */ - if (err != Z_OK) { - - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; + { + uLong len = srv_page_size; + if (Z_OK != uncompress(tmp_buf, &len, + buf + header_len, + uLong(actual_size)) + && len != srv_page_size) { + return 0; } - ut_error; } break; - #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: - err = LZ4_decompress_fast((const char *)buf+header_len, (char *)in_buf, len); - - if (err != (int)actual_size) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + if (LZ4_decompress_safe(reinterpret_cast(buf) + + header_len, + reinterpret_cast(tmp_buf), + actual_size, srv_page_size) + == int(srv_page_size)) { + break; } - break; + return 0; #endif /* HAVE_LZ4 */ #ifdef HAVE_LZO case PAGE_LZO_ALGORITHM: { - ulint olen = 0; - lzo_uint olen_lzo = olen; - err = lzo1x_decompress((const unsigned char *)buf+header_len, - actual_size,(unsigned char *)in_buf, &olen_lzo, NULL); - - olen = olen_lzo; - - if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + lzo_uint len_lzo = srv_page_size; + if (LZO_E_OK == lzo1x_decompress_safe( + buf + header_len, + actual_size, tmp_buf, &len_lzo, NULL) + && len_lzo == srv_page_size) { + break; } - break; + return 0; } #endif /* HAVE_LZO */ #ifdef HAVE_LZMA case PAGE_LZMA_ALGORITHM: { - - lzma_ret ret; size_t src_pos = 0; size_t dst_pos = 0; uint64_t memlimit = UINT64_MAX; - ret = lzma_stream_buffer_decode( - &memlimit, - 0, - NULL, - buf+header_len, - &src_pos, - actual_size, - in_buf, - &dst_pos, - len); - - - if (ret != LZMA_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only %ld bytes" - " size " ULINTPF "len " ULINTPF ".", - dst_pos, actual_size, len); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + if (LZMA_OK == lzma_stream_buffer_decode( + &memlimit, 0, NULL, buf + header_len, + &src_pos, actual_size, tmp_buf, &dst_pos, + srv_page_size) + && dst_pos == srv_page_size) { + break; } - - break; + return 0; } #endif /* HAVE_LZMA */ #ifdef HAVE_BZIP2 case PAGE_BZIP2_ALGORITHM: { - unsigned int dst_pos = UNIV_PAGE_SIZE; - - err = BZ2_bzBuffToBuffDecompress( - (char *)in_buf, - &dst_pos, - (char *)(buf+header_len), - actual_size, - 1, - 0); - - if (err != BZ_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only %du bytes" - " size " ULINTPF " len " ULINTPF " err %d.", - dst_pos, actual_size, len, err); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + unsigned int dst_pos = srv_page_size; + if (BZ_OK == BZ2_bzBuffToBuffDecompress( + reinterpret_cast(tmp_buf), + &dst_pos, + reinterpret_cast(buf) + header_len, + actual_size, 1, 0) + && dst_pos == srv_page_size) { + break; } - break; + return 0; } #endif /* HAVE_BZIP2 */ #ifdef HAVE_SNAPPY - case PAGE_SNAPPY_ALGORITHM: - { - snappy_status cstatus; - ulint olen = UNIV_PAGE_SIZE; - - cstatus = snappy_uncompress( - (const char *)(buf+header_len), - (size_t)actual_size, - (char *)in_buf, - (size_t*)&olen); - - if (cstatus != SNAPPY_OK || olen != UNIV_PAGE_SIZE) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only " ULINTPF " bytes" - " size " ULINTPF " len " ULINTPF " err %d.", - olen, actual_size, len, (int)cstatus); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + case PAGE_SNAPPY_ALGORITHM: { + size_t olen = srv_page_size; + + if (SNAPPY_OK == snappy_uncompress( + reinterpret_cast(buf) + header_len, + actual_size, + reinterpret_cast(tmp_buf), &olen) + && olen == srv_page_size) { + break; } - - break; + return 0; } #endif /* HAVE_SNAPPY */ - default: - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but compression algorithm %s" - " is not known." - ,fil_get_compression_alg_name(compression_alg)); - - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; - break; } srv_stats.pages_page_decompressed.inc(); - - /* Copy the uncompressed page to the buffer pool, not - really any other options. */ - memcpy(buf, in_buf, len); - -error_return: - if (page_buf != in_buf) { - ut_free(in_buf); - } + memcpy(buf, tmp_buf, srv_page_size); + return actual_size; } diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 1cf37f366d7e3f9be25461813b4f18cecb219082..b20c59c4d8c1e2b1f609756a93e7bd84526879d2 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -3027,7 +3027,7 @@ fseg_free_page_low( /* Drop search system page hash index if the page is found in the pool and is hashed */ - btr_search_drop_page_hash_when_freed(space, zip_size, page); + btr_search_drop_page_hash_when_freed(space, page); descr = xdes_get_descriptor(space, zip_size, page, mtr); @@ -3247,7 +3247,7 @@ fseg_free_extent( found in the pool and is hashed */ btr_search_drop_page_hash_when_freed( - space, zip_size, first_page_in_extent + i); + space, first_page_in_extent + i); } } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index dc121083c6e29198cd72642dfd42cdff7a8812cf..f65265fd565490a990355823a078930cecbed612 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, 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 @@ -4628,6 +4628,7 @@ fts_sync( ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped + || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } @@ -4638,17 +4639,6 @@ fts_sync( end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); - if (error == DB_SUCCESS) { - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing) { - index_cache->index->index_fts_syncing - = false; - } - } - } } else { fts_sync_rollback(sync); } @@ -4657,12 +4647,9 @@ fts_sync( /* Clear fts syncing flags of any indexes incase sync is interrupeted */ for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing == true) { - index_cache->index->index_fts_syncing = false; - } + static_cast( + ib_vector_get(cache->indexes, i)) + ->index->index_fts_syncing = false; } sync->interrupted = false; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b66f74873a92d5b7152ebbc8885c8fc73b66e85a..0daa89b6e9a23cd476a51434b617ff5e9d72e619 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,10 +1,10 @@ /***************************************************************************** -Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -55,7 +55,7 @@ MYSQL_PLUGIN_IMPORT extern char mysql_unpacked_real_data_home[]; #include #endif -#include +#include /** @file ha_innodb.cc */ @@ -314,6 +314,23 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = { NULL }; +/** Possible values for system variable "innodb_default_row_format". */ +static const char* innodb_default_row_format_names[] = { + "redundant", + "compact", + "dynamic", + NullS +}; + +/** Used to define an enumerate type of the system variable +innodb_default_row_format. */ +static TYPELIB innodb_default_row_format_typelib = { + array_elements(innodb_default_row_format_names) - 1, + "innodb_default_row_format_typelib", + innodb_default_row_format_names, + NULL +}; + /* The following counter is used to convey information to InnoDB about server activity: in case of normal DML ops it is not sensible to call srv_active_wake_master_thread after each @@ -334,6 +351,35 @@ static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = { "all" /* IBUF_USE_ALL */ }; + +/** Note we cannot use rec_format_enum because we do not allow +COMPRESSED row format for innodb_default_row_format option. */ +enum default_row_format_enum { + DEFAULT_ROW_FORMAT_REDUNDANT = 0, + DEFAULT_ROW_FORMAT_COMPACT = 1, + DEFAULT_ROW_FORMAT_DYNAMIC = 2 +}; + +/** Convert an InnoDB ROW_FORMAT value. +@param[in] row_format row_format from "innodb_default_row_format" +@return converted ROW_FORMAT */ +static rec_format_t get_row_format(ulong row_format) +{ + switch (row_format) { + case DEFAULT_ROW_FORMAT_REDUNDANT: + return REC_FORMAT_REDUNDANT; + case DEFAULT_ROW_FORMAT_COMPACT: + return REC_FORMAT_COMPACT; + case DEFAULT_ROW_FORMAT_DYNAMIC: + return REC_FORMAT_DYNAMIC; + default: + ut_ad(0); + return REC_FORMAT_COMPACT; + } +} + +static ulong innodb_default_row_format; + /* Call back function array defined by MySQL and used to retrieve FTS results. */ const struct _ft_vft ft_vft_result = {NULL, @@ -1153,7 +1199,9 @@ innobase_close_connection( THD* thd); /*!< in: MySQL thread handle for which to close the connection */ -static void innobase_kill_query(handlerton *hton, THD* thd, enum thd_kill_levels level); +/** Cancel any pending lock request associated with the current THD. +@sa THD::awake() @sa ha_kill_query() */ +static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels); static void innobase_commit_ordered(handlerton *hton, THD* thd, bool all); /*****************************************************************//** @@ -2365,8 +2413,12 @@ innobase_mysql_tmpfile( fd2 = -1; } } +#else +#ifdef F_DUPFD_CLOEXEC + fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); #else fd2 = dup(fd); +#endif #endif if (fd2 < 0) { DBUG_PRINT("error",("Got error %d on dup",fd2)); @@ -2801,8 +2853,7 @@ ha_innobase::ha_innobase( (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) | HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT), start_of_scan(0), - num_write_row(0), - ha_partition_stats(NULL) + num_write_row(0) {} /*********************************************************************//** @@ -4845,23 +4896,12 @@ innobase_close_thd( UNIV_INTERN void lock_cancel_waiting_and_release(lock_t* lock); -/*****************************************************************//** -Cancel any pending lock request associated with the current THD. */ -static -void -innobase_kill_query( -/*======================*/ - handlerton* hton, /*!< in: innobase handlerton */ - THD* thd, /*!< in: MySQL thread being killed */ - enum thd_kill_levels level) /*!< in: kill level */ +/** Cancel any pending lock request associated with the current THD. +@sa THD::awake() @sa ha_kill_query() */ +static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels) { - trx_t* trx; - DBUG_ENTER("innobase_kill_query"); - DBUG_ASSERT(hton == innodb_hton_ptr); - #ifdef WITH_WSREP - wsrep_thd_LOCK(thd); if (wsrep_thd_get_conflict_state(thd) != NO_CONFLICT) { /* if victim has been signaled by BF thread and/or aborting is already progressing, following query aborting is not necessary @@ -4869,56 +4909,41 @@ innobase_kill_query( Also, BF thread should own trx mutex for the victim, which would conflict with trx_mutex_enter() below */ - wsrep_thd_UNLOCK(thd); DBUG_VOID_RETURN; } - wsrep_thd_UNLOCK(thd); #endif /* WITH_WSREP */ - trx = thd_to_trx(thd); - if (trx && trx->lock.wait_lock) { - /* In wsrep BF we have already took lock_sys and trx - mutex either on wsrep_abort_transaction() or - before wsrep_kill_victim(). In replication we - could own lock_sys mutex taken in - lock_deadlock_check_and_resolve(). */ - - WSREP_DEBUG("Killing victim trx %p BF %d trx BF %d trx_id " TRX_ID_FMT " ABORT %d thd %p" - " current_thd %p BF %d wait_lock_modes: %s\n", - trx, wsrep_thd_is_BF(trx->mysql_thd, FALSE), - wsrep_thd_is_BF(thd, FALSE), - trx->id, trx->abort_type, - trx->mysql_thd, - current_thd, - wsrep_thd_is_BF(current_thd, FALSE), - lock_get_info(trx->lock.wait_lock).c_str()); - - if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE) - && trx->abort_type == TRX_SERVER_ABORT) { - ut_ad(!lock_mutex_own()); - lock_mutex_enter(); - } - - if (trx->abort_type != TRX_WSREP_ABORT) { - trx_mutex_enter(trx); - } + if (trx_t* trx = thd_to_trx(thd)) { + ut_ad(trx->mysql_thd == thd); - ut_ad(lock_mutex_own()); - ut_ad(trx_mutex_own(trx)); - - /* Cancel a pending lock request. */ - if (trx->lock.wait_lock) { - lock_cancel_waiting_and_release(trx->lock.wait_lock); + switch (trx->abort_type) { +#ifdef WITH_WSREP + case TRX_WSREP_ABORT: + break; +#endif + case TRX_SERVER_ABORT: + if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + lock_mutex_enter(); + } + /* fall through */ + case TRX_REPLICATION_ABORT: + trx_mutex_enter(trx); } - - if (trx->abort_type != TRX_WSREP_ABORT) { + /* Cancel a pending lock request if there are any */ + lock_trx_handle_wait(trx); + switch (trx->abort_type) { +#ifdef WITH_WSREP + case TRX_WSREP_ABORT: + break; +#endif + case TRX_SERVER_ABORT: + if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + lock_mutex_exit(); + } + /* fall through */ + case TRX_REPLICATION_ABORT: trx_mutex_exit(trx); } - - if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - trx->abort_type == TRX_SERVER_ABORT) { - lock_mutex_exit(); - } } DBUG_VOID_RETURN; @@ -8414,14 +8439,12 @@ ha_innobase::write_row( user_thd); #ifdef WITH_WSREP - if (!error_result && - wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && - wsrep_on(user_thd) && - !wsrep_consistency_check(user_thd) && - !wsrep_thd_ignore_table(user_thd)) - { - if (wsrep_append_keys(user_thd, false, record, NULL)) - { + if (!error_result + && wsrep_on(user_thd) + && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE + && !wsrep_consistency_check(user_thd) + && !wsrep_thd_ignore_table(user_thd)) { + if (wsrep_append_keys(user_thd, false, record, NULL)) { DBUG_PRINT("wsrep", ("row key failed")); error_result = HA_ERR_INTERNAL_ERROR; goto wsrep_error; @@ -9042,7 +9065,7 @@ ha_innobase::unlock_row(void) But there are some calls to this function from the SQL layer when the transaction is in state TRX_STATE_NOT_STARTED. The check on prebuilt->select_lock_type above gets around this issue. */ - ut_ad(trx_state_eq(prebuilt->trx, TRX_STATE_ACTIVE)); + ut_ad(trx_state_eq(prebuilt->trx, TRX_STATE_ACTIVE, true)); switch (prebuilt->row_read_type) { case ROW_READ_WITH_LOCKS: @@ -11326,8 +11349,6 @@ create_options_are_invalid( CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; break; case ROW_TYPE_DYNAMIC: - CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace); - CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; /* ROW_FORMAT=DYNAMIC also shuns KEY_BLOCK_SIZE */ /* fall through */ case ROW_TYPE_COMPACT: @@ -11561,7 +11582,8 @@ innobase_table_flags( bool zip_allowed = true; ulint zip_ssize = 0; enum row_type row_format; - rec_format_t innodb_row_format = REC_FORMAT_COMPACT; + rec_format_t innodb_row_format = + get_row_format(innodb_default_row_format); bool use_data_dir; ha_table_option_struct *options= form->s->option_struct; @@ -11708,37 +11730,29 @@ innobase_table_flags( /* Validate the row format. Correct it if necessary */ switch (row_format) { + case ROW_TYPE_DEFAULT: + break; case ROW_TYPE_REDUNDANT: innodb_row_format = REC_FORMAT_REDUNDANT; break; - case ROW_TYPE_COMPRESSED: case ROW_TYPE_DYNAMIC: + innodb_row_format = REC_FORMAT_DYNAMIC; + break; + case ROW_TYPE_COMPRESSED: if (!use_tablespace) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_per_table."); } else if (file_format_allowed == UNIV_FORMAT_A) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_format > Antelope."); } else { - switch(row_format) { - case ROW_TYPE_COMPRESSED: - innodb_row_format = REC_FORMAT_COMPRESSED; - break; - case ROW_TYPE_DYNAMIC: - innodb_row_format = REC_FORMAT_DYNAMIC; - break; - default: - /* Not possible, avoid compiler warning */ - break; - } + innodb_row_format = REC_FORMAT_COMPRESSED; break; /* Correct row_format */ } zip_allowed = FALSE; @@ -11752,10 +11766,8 @@ innobase_table_flags( ER_ILLEGAL_HA_CREATE_OPTION, "InnoDB: assuming ROW_FORMAT=COMPACT."); /* fall through */ - case ROW_TYPE_DEFAULT: - /* If we fell through, set row format to Compact. */ - row_format = ROW_TYPE_COMPACT; case ROW_TYPE_COMPACT: + innodb_row_format = REC_FORMAT_COMPACT; break; } @@ -13894,6 +13906,7 @@ ha_innobase::optimize( This works OK otherwise, but MySQL locks the entire table during calls to OPTIMIZE, which is undesirable. */ + bool try_alter = true; if (srv_defragment) { int err; @@ -13901,7 +13914,7 @@ ha_innobase::optimize( err = defragment_table(prebuilt->table->name, NULL, false); if (err == 0) { - return (HA_ADMIN_OK); + try_alter = false; } else { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, err, @@ -13909,9 +13922,7 @@ ha_innobase::optimize( prebuilt->table->name, err); if(err == ER_SP_ALREADY_EXISTS) { - return (HA_ADMIN_OK); - } else { - return (HA_ADMIN_TRY_ALTER); + try_alter = false; } } } @@ -13922,11 +13933,10 @@ ha_innobase::optimize( fts_sync_table(prebuilt->table, false, true, false); fts_optimize_table(prebuilt->table); } - return(HA_ADMIN_OK); - } else { - - return(HA_ADMIN_TRY_ALTER); + try_alter = false; } + + return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK; } /*******************************************************************//** @@ -14743,6 +14753,7 @@ ha_innobase::start_stmt( case SQLCOM_INSERT: case SQLCOM_UPDATE: case SQLCOM_DELETE: + case SQLCOM_REPLACE: init_table_handle_for_HANDLER(); prebuilt->select_lock_type = LOCK_X; prebuilt->stored_select_lock_type = LOCK_X; @@ -16737,13 +16748,6 @@ innodb_max_dirty_pages_pct_lwm_update( srv_max_dirty_pages_pct_lwm = in_val; } -UNIV_INTERN -void -ha_innobase::set_partition_owner_stats(ha_statistics *stats) -{ - ha_partition_stats= stats; -} - /************************************************************//** Validate the file format name and return its corresponding id. @return valid file format id */ @@ -18603,8 +18607,10 @@ wsrep_innobase_kill_one_trx( thd_get_thread_id(thd), victim_trx->id); - WSREP_DEBUG("Aborting query: %s", - (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void"); + WSREP_DEBUG("Aborting query: %s conf %d trx: %lu", + (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void", + wsrep_thd_conflict_state(thd, FALSE), + wsrep_thd_ws_handle(thd)->trx_id); wsrep_thd_LOCK(thd); DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock", @@ -18667,7 +18673,7 @@ wsrep_innobase_kill_one_trx( wsrep_t *wsrep= get_wsrep(); rcode = wsrep->abort_pre_commit( wsrep, bf_seqno, - (wsrep_trx_id_t)victim_trx->id + (wsrep_trx_id_t)wsrep_thd_ws_handle(thd)->trx_id ); switch (rcode) { @@ -18724,7 +18730,7 @@ wsrep_innobase_kill_one_trx( thd_get_thread_id(thd))); WSREP_DEBUG("kill query for: %ld", thd_get_thread_id(thd)); - /* Note that innobase_kill_connection will take lock_mutex + /* Note that innobase_kill_query will take lock_mutex and trx_mutex */ wsrep_thd_UNLOCK(thd); wsrep_thd_awake(thd, signal); @@ -18790,12 +18796,14 @@ wsrep_abort_transaction( my_bool signal) { DBUG_ENTER("wsrep_innobase_abort_thd"); - trx_t* victim_trx = thd_to_trx(victim_thd); - trx_t* bf_trx = (bf_thd) ? thd_to_trx(bf_thd) : NULL; + + trx_t* victim_trx = thd_to_trx(victim_thd); + trx_t* bf_trx = (bf_thd) ? thd_to_trx(bf_thd) : NULL; - WSREP_DEBUG("abort transaction: BF: %s victim: %s", - wsrep_thd_query(bf_thd), - wsrep_thd_query(victim_thd)); + WSREP_DEBUG("abort transaction: BF: %s victim: %s victim conf: %d", + wsrep_thd_query(bf_thd), + wsrep_thd_query(victim_thd), + wsrep_thd_conflict_state(victim_thd, FALSE)); if (victim_trx) { lock_mutex_enter(); @@ -18822,29 +18830,27 @@ wsrep_abort_transaction( static int innobase_wsrep_set_checkpoint(handlerton* hton, const XID* xid) { DBUG_ASSERT(hton == innodb_hton_ptr); - if (wsrep_is_wsrep_xid(xid)) { - mtr_t mtr; - mtr_start(&mtr); - trx_sysf_t* sys_header = trx_sysf_get(&mtr); - trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); - mtr_commit(&mtr); - innobase_flush_logs(hton); - return 0; - } else { - return 1; - } + if (wsrep_is_wsrep_xid(xid)) { + mtr_t mtr; + mtr_start(&mtr); + trx_sysf_t* sys_header = trx_sysf_get(&mtr); + trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); + mtr_commit(&mtr); + innobase_flush_logs(hton); + return 0; + } else { + return 1; + } } static int innobase_wsrep_get_checkpoint(handlerton* hton, XID* xid) { DBUG_ASSERT(hton == innodb_hton_ptr); - trx_sys_read_wsrep_checkpoint(xid); - return 0; + trx_sys_read_wsrep_checkpoint(xid); + return 0; } -static void -wsrep_fake_trx_id( -/*==================*/ +static void wsrep_fake_trx_id( handlerton *hton, THD *thd) /*!< in: user thread handle */ { @@ -19805,6 +19811,14 @@ static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled, "may have negative impact on performance (off by default)", NULL, innodb_cmp_per_index_update, FALSE); +static MYSQL_SYSVAR_ENUM(default_row_format, innodb_default_row_format, + PLUGIN_VAR_RQCMDARG, + "The default ROW FORMAT for all innodb tables created without explicit" + " ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC." + " The ROW_FORMAT value COMPRESSED is not allowed", + NULL, NULL, DEFAULT_ROW_FORMAT_COMPACT, + &innodb_default_row_format_typelib); + #ifdef UNIV_DEBUG static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT, @@ -20174,6 +20188,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(sync_array_size), MYSQL_SYSVAR(compression_failure_threshold_pct), MYSQL_SYSVAR(compression_pad_pct_max), + MYSQL_SYSVAR(default_row_format), MYSQL_SYSVAR(simulate_comp_failures), #ifdef UNIV_DEBUG MYSQL_SYSVAR(trx_rseg_n_slots_debug), diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 300f49c93f98abb6a615cb17f5d677692f23a8d2..9c838910434dd1f2d15d8828811d1d605f1ef16f 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -100,8 +100,6 @@ class ha_innobase: public handler or undefined */ uint num_write_row; /*!< number of write_row() calls */ - ha_statistics* ha_partition_stats; /*!< stats of the partition owner - handler (if there is one) */ uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, const uchar* record); inline void update_thd(THD* thd); @@ -316,7 +314,6 @@ class ha_innobase: public handler Alter_inplace_info* ha_alter_info, bool commit); /** @} */ - void set_partition_owner_stats(ha_statistics *stats); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); private: diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index f8e61631dfe5cdb921d0cccffc352f031142e8df..9f44b64a235a9d13dcab466fb7bbbc55e74b7bb1 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1619,6 +1619,7 @@ innobase_create_index_def( if (key_clustered) { DBUG_ASSERT(!(key->flags & HA_FULLTEXT)); + DBUG_ASSERT(key->flags & HA_NOSAME); index->ind_type |= DICT_CLUSTERED; } else if (key->flags & HA_FULLTEXT) { DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK @@ -1934,14 +1935,9 @@ innobase_create_key_defs( ulint primary_key_number; if (new_primary) { - if (n_add == 0) { - DBUG_ASSERT(got_default_clust); - DBUG_ASSERT(altered_table->s->primary_key - == 0); - primary_key_number = 0; - } else { - primary_key_number = *add; - } + DBUG_ASSERT(n_add || got_default_clust); + DBUG_ASSERT(n_add || !altered_table->s->primary_key); + primary_key_number = altered_table->s->primary_key; } else if (got_default_clust) { /* Create the GEN_CLUST_INDEX */ index_def_t* index = indexdef++; @@ -4417,12 +4413,16 @@ rollback_inplace_alter_table( row_mysql_lock_data_dictionary(ctx->trx); if (ctx->need_rebuild()) { - dberr_t err; - ulint flags = ctx->new_table->flags; - /* DML threads can access ctx->new_table via the online rebuild log. Free it first. */ innobase_online_rebuild_log_free(prebuilt->table); + } + + if (!ctx->new_table) { + ut_ad(ctx->need_rebuild()); + } else if (ctx->need_rebuild()) { + dberr_t err; + ulint flags = ctx->new_table->flags; /* Since the FTS index specific auxiliary tables has not yet registered with "table->fts" by fts_add_index(), @@ -4879,13 +4879,15 @@ innobase_rename_columns_cache( } /** Get the auto-increment value of the table on commit. -@param ha_alter_info Data used during in-place alter -@param ctx In-place ALTER TABLE context -@param altered_table MySQL table that is being altered -@param old_table MySQL table as it is before the ALTER operation -@return the next auto-increment value (0 if not present) */ +@param[in] ha_alter_info Data used during in-place alter +@param[in,out] ctx In-place ALTER TABLE context + return autoinc value in ctx->max_autoinc +@param altered_table[in] MySQL table that is being altered +@param old_table[in] MySQL table as it is before the ALTER operation +retval true Failure +@retval false Success*/ static MY_ATTRIBUTE((nonnull, warn_unused_result)) -ulonglong +bool commit_get_autoinc( /*===============*/ Alter_inplace_info* ha_alter_info, @@ -4893,23 +4895,28 @@ commit_get_autoinc( const TABLE* altered_table, const TABLE* old_table) { - ulonglong max_autoinc; DBUG_ENTER("commit_get_autoinc"); if (!altered_table->found_next_number_field) { /* There is no AUTO_INCREMENT column in the table after the ALTER operation. */ - max_autoinc = 0; + ctx->max_autoinc = 0; } else if (ctx->add_autoinc != ULINT_UNDEFINED) { /* An AUTO_INCREMENT column was added. Get the last value from the sequence, which may be based on a supplied AUTO_INCREMENT value. */ - max_autoinc = ctx->sequence.last(); + ctx->max_autoinc = ctx->sequence.last(); } else if ((ha_alter_info->handler_flags & Alter_inplace_info::CHANGE_CREATE_OPTION) && (ha_alter_info->create_info->used_fields & HA_CREATE_USED_AUTO)) { + + /* Check if the table is discarded */ + if(dict_table_is_discarded(ctx->old_table)) { + DBUG_RETURN(true); + } + /* An AUTO_INCREMENT value was supplied, but the table was not rebuilt. Get the user-supplied value or the last value from the sequence. */ @@ -4924,7 +4931,8 @@ commit_get_autoinc( dict_index_t* index = dict_table_get_index_on_name( ctx->old_table, autoinc_key->name); - max_autoinc = ha_alter_info->create_info->auto_increment_value; + ctx->max_autoinc = + ha_alter_info->create_info->auto_increment_value; dict_table_autoinc_lock(ctx->old_table); @@ -4933,8 +4941,8 @@ commit_get_autoinc( if (err != DB_SUCCESS) { ut_ad(0); - max_autoinc = 0; - } else if (max_autoinc <= max_value_table) { + ctx->max_autoinc = 0; + } else if (ctx->max_autoinc <= max_value_table) { ulonglong col_max_value; ulonglong offset; @@ -4942,7 +4950,7 @@ commit_get_autoinc( old_table->found_next_number_field); offset = ctx->prebuilt->autoinc_offset; - max_autoinc = innobase_next_autoinc( + ctx->max_autoinc = innobase_next_autoinc( max_value_table, 1, 1, offset, col_max_value); } @@ -4952,11 +4960,11 @@ commit_get_autoinc( Read the old counter value from the table. */ ut_ad(old_table->found_next_number_field); dict_table_autoinc_lock(ctx->old_table); - max_autoinc = ctx->old_table->autoinc; + ctx->max_autoinc = ctx->old_table->autoinc; dict_table_autoinc_unlock(ctx->old_table); } - DBUG_RETURN(max_autoinc); + DBUG_RETURN(false); } /** Add or drop foreign key constraints to the data dictionary tables, @@ -5782,21 +5790,6 @@ ha_innobase::commit_inplace_alter_table( ut_ad(prebuilt->table == ctx0->old_table); ha_alter_info->group_commit_ctx = NULL; - /* Free the ctx->trx of other partitions, if any. We will only - use the ctx0->trx here. Others may have been allocated in - the prepare stage. */ - - for (inplace_alter_handler_ctx** pctx = &ctx_array[1]; *pctx; - pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); - - if (ctx->trx) { - trx_free_for_mysql(ctx->trx); - ctx->trx = NULL; - } - } - trx_start_if_not_started_xa(prebuilt->trx); for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { @@ -5951,8 +5944,13 @@ ha_innobase::commit_inplace_alter_table( DBUG_ASSERT(new_clustered == ctx->need_rebuild()); - ctx->max_autoinc = commit_get_autoinc( - ha_alter_info, ctx, altered_table, table); + if (commit_get_autoinc(ha_alter_info, ctx, altered_table, + table)) { + fail = true; + my_error(ER_TABLESPACE_DISCARDED, MYF(0), + table->s->table_name.str); + goto rollback_trx; + } if (ctx->need_rebuild()) { ctx->tmp_name = dict_mem_create_temporary_tablename( @@ -5984,6 +5982,8 @@ ha_innobase::commit_inplace_alter_table( #endif } +rollback_trx: + /* Commit or roll back the changes to the data dictionary. */ if (fail) { @@ -6175,10 +6175,6 @@ ha_innobase::commit_inplace_alter_table( covering all partitions. */ share->idx_trans_tbl.index_count = 0; - if (trx == ctx0->trx) { - ctx0->trx = NULL; - } - /* Tell the InnoDB server that there might be work for utility threads: */ @@ -6201,10 +6197,31 @@ ha_innobase::commit_inplace_alter_table( } row_mysql_unlock_data_dictionary(trx); - trx_free_for_mysql(trx); + if (trx != ctx0->trx) { + trx_free_for_mysql(trx); + } DBUG_RETURN(true); } + if (trx == ctx0->trx) { + ctx0->trx = NULL; + } + + /* Free the ctx->trx of other partitions, if any. We will only + use the ctx0->trx here. Others may have been allocated in + the prepare stage. */ + + for (inplace_alter_handler_ctx** pctx = &ctx_array[1]; *pctx; + pctx++) { + ha_innobase_inplace_ctx* ctx + = static_cast(*pctx); + + if (ctx->trx) { + trx_free_for_mysql(ctx->trx); + ctx->trx = NULL; + } + } + /* Release the table locks. */ trx_commit_for_mysql(prebuilt->trx); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 2c82c1b49318789ab2fd8e0cb783a31679ad57c3..31bb984f1964a8e9429bf0221e84e077a3db078f 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -4935,9 +4935,11 @@ i_s_innodb_buffer_page_fill( mutex_enter(&dict_sys->mutex); - if (const dict_index_t* index = - dict_index_get_if_in_cache_low( - page_info->index_id)) { + const dict_index_t* index = + dict_index_get_if_in_cache_low( + page_info->index_id); + + if (index) { table_name_end = innobase_convert_name( table_name, sizeof(table_name), index->table_name, @@ -4960,7 +4962,10 @@ i_s_innodb_buffer_page_fill( OK(ret); - fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull(); + if (index) { + fields[IDX_BUFFER_PAGE_TABLE_NAME] + ->set_notnull(); + } } OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store( @@ -5637,9 +5642,11 @@ i_s_innodb_buf_page_lru_fill( mutex_enter(&dict_sys->mutex); - if (const dict_index_t* index = - dict_index_get_if_in_cache_low( - page_info->index_id)) { + const dict_index_t* index = + dict_index_get_if_in_cache_low( + page_info->index_id); + + if (index) { table_name_end = innobase_convert_name( table_name, sizeof(table_name), index->table_name, @@ -5662,7 +5669,10 @@ i_s_innodb_buf_page_lru_fill( OK(ret); - fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull(); + if (index) { + fields[IDX_BUF_LRU_PAGE_TABLE_NAME] + ->set_notnull(); + } } OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store( diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 2b406e116b0ffd83ac62a5fe21a875166b92e1e1..17fe3ae7511fe57220afa95a4d83e7ba1b896b40 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -5177,6 +5177,11 @@ ibuf_check_bitmap_on_import( bitmap_page = ibuf_bitmap_get_map_page( space_id, page_no, zip_size, &mtr); + if (!bitmap_page) { + mutex_exit(&ibuf_mutex); + return DB_CORRUPTION; + } + for (i = FSP_IBUF_BITMAP_OFFSET + 1; i < page_size; i++) { const ulint offset = page_no + i; diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index c95ca28057aaae871a286d4a0fd20aa862819a3f..4e1df7066d1857dc337d6c2ef20f88531b46a795 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, 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 @@ -141,17 +142,11 @@ btr_search_drop_page_hash_index( s- or x-latched, or an index page for which we know that block->buf_fix_count == 0 */ -/********************************************************************//** -Drops a possible page hash index when a page is evicted from the buffer pool -or freed in a file segment. */ +/** Drop possible adaptive hash index entries when a page is evicted +from the buffer pool or freed in a file, or the index is being dropped. */ UNIV_INTERN void -btr_search_drop_page_hash_when_freed( -/*=================================*/ - ulint space, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ - ulint page_no); /*!< in: page number */ +btr_search_drop_page_hash_when_freed(ulint space, ulint page_no); /********************************************************************//** Updates the page hash index when a single record is inserted on a page. */ UNIV_INTERN diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 857bdf9d2be77019ab6a6a586a0d5d66b1a75237..aca4e58810c66343a1a5226fc038f8818c9551a9 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -39,6 +39,7 @@ Created 11/5/1995 Heikki Tuuri #include "ut0rbt.h" #include "os0proc.h" #include "log0log.h" +#include "my_atomic.h" /** @name Modes for buf_page_get_gen */ /* @{ */ @@ -1506,45 +1507,16 @@ buf_page_encrypt_before_write( buf_page_t* bpage, byte* src_frame); -/********************************************************************** -The hook that is called after page is written to disk. -The function releases any resources needed for encryption that was allocated -in buf_page_encrypt_before_write */ -UNIV_INTERN -ibool -buf_page_encrypt_after_write( -/*=========================*/ - buf_page_t* page); /*!< in/out: buffer page that was flushed */ - -/********************************************************************//** -The hook that is called just before a page is read from disk. -The function allocates memory that is used to temporarily store disk content -before getting decrypted */ -UNIV_INTERN -byte* -buf_page_decrypt_before_read( -/*=========================*/ - buf_page_t* page, /*!< in/out: buffer page read from disk */ - ulint zip_size); /*!< in: compressed page size, or 0 */ - -/********************************************************************//** -The hook that is called just after a page is read from disk. -The function decrypt disk content into buf_page_t and releases the -temporary buffer that was allocated in buf_page_decrypt_before_read */ -UNIV_INTERN -bool -buf_page_decrypt_after_read( -/*========================*/ - buf_page_t* page); /*!< in/out: buffer page read from disk */ - /** @brief The temporary memory structure. NOTE! The definition appears here only for other modules of this directory (buf) to see it. Do not use from outside! */ typedef struct { - bool reserved; /*!< true if this slot is reserved +private: + int32 reserved; /*!< true if this slot is reserved */ +public: byte* crypt_buf; /*!< for encryption the data needs to be copied to a separate buffer before it's encrypted&written. this as a page can be @@ -1555,6 +1527,21 @@ typedef struct { byte* out_buf; /*!< resulting buffer after encryption/compression. This is a pointer and not allocated. */ + + /** Release the slot */ + void release() + { + my_atomic_store32_explicit(&reserved, false, + MY_MEMORY_ORDER_RELAXED); + } + + /** Acquire the slot + @return whether the slot was acquired */ + bool acquire() + { + return !my_atomic_fas32_explicit(&reserved, true, + MY_MEMORY_ORDER_RELAXED); + } } buf_tmp_buffer_t; /** The common buffer control block structure diff --git a/storage/innobase/include/buf0lru.h b/storage/innobase/include/buf0lru.h index 308bda20c7b4af5f207b753dbf92d31a4d60109d..623883433c2dd2ab4a6e86ab0d3a746d90700a49 100644 --- a/storage/innobase/include/buf0lru.h +++ b/storage/innobase/include/buf0lru.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -34,6 +34,7 @@ Created 11/5/1995 Heikki Tuuri // Forward declaration struct trx_t; +struct dict_table_t; /******************************************************************//** Returns TRUE if less than 25 % of the buffer pool is available. This can be @@ -52,14 +53,15 @@ These are low-level functions /** Minimum LRU list length for which the LRU_old pointer is defined */ #define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */ +/** Drop the adaptive hash index for a tablespace. +@param[in,out] table table */ +UNIV_INTERN void buf_LRU_drop_page_hash_for_tablespace(dict_table_t* table); + /** Empty the flush list for all pages belonging to a tablespace. @param[in] id tablespace identifier @param[in] trx transaction, for checking for user interrupt; - or NULL if nothing is to be written -@param[in] drop_ahi whether to drop the adaptive hash index */ -UNIV_INTERN -void -buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx, bool drop_ahi=false); + or NULL if nothing is to be written */ +UNIV_INTERN void buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic index eaa90f6d33acf0a4a98a2be8691dc33e330effdf..c04da618a849dc1c27a3033977636b238f191efd 100644 --- a/storage/innobase/include/data0type.ic +++ b/storage/innobase/include/data0type.ic @@ -524,6 +524,7 @@ dtype_get_fixed_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: @@ -601,6 +602,7 @@ dtype_get_min_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 312b09e1f2d9abacdbbf6965ac538b9b6497bbe9..a8dc9e14381c846a9faf068c3dc1cb5c588c2a42 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -173,8 +173,7 @@ extern fil_addr_t fil_addr_null; #define FIL_PAGE_TYPE_BLOB 10 /*!< Uncompressed BLOB page */ #define FIL_PAGE_TYPE_ZBLOB 11 /*!< First compressed BLOB page */ #define FIL_PAGE_TYPE_ZBLOB2 12 /*!< Subsequent compressed BLOB page */ -#define FIL_PAGE_TYPE_COMPRESSED 13 /*!< Compressed page */ -#define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_COMPRESSED +#define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_ZBLOB2 /*!< Last page type */ /* @} */ @@ -281,10 +280,6 @@ struct fil_space_t { an insert buffer merge request for a page because it actually was for the previous incarnation of the space */ - ibool stop_ios;/*!< TRUE if we want to rename the - .ibd file of tablespace and want to - stop temporarily posting of new i/o - requests on the file */ bool stop_new_ops; /*!< we set this TRUE when we start deleting a single-table tablespace. @@ -346,9 +341,6 @@ struct fil_space_t { bool is_in_unflushed_spaces; /*!< true if this space is currently in unflushed_spaces */ - bool printed_compression_failure; - /*!< true if we have already printed - compression failure */ fil_space_crypt_t* crypt_data; /*!< tablespace crypt data or NULL */ ulint file_block_size; @@ -1292,107 +1284,6 @@ fil_delete_file( /*============*/ const char* path); /*!< in: filepath of the ibd tablespace */ -/** Callback functor. */ -struct PageCallback { - - /** - Default constructor */ - PageCallback() - : - m_zip_size(), - m_page_size(), - m_filepath() UNIV_NOTHROW {} - - virtual ~PageCallback() UNIV_NOTHROW {} - - /** - Called for page 0 in the tablespace file at the start. - @param file_size - size of the file in bytes - @param block - contents of the first page in the tablespace file - @retval DB_SUCCESS or error code.*/ - virtual dberr_t init( - os_offset_t file_size, - const buf_block_t* block) UNIV_NOTHROW = 0; - - /** - Called for every page in the tablespace. If the page was not - updated then its state must be set to BUF_PAGE_NOT_USED. For - compressed tables the page descriptor memory will be at offset: - block->frame + UNIV_PAGE_SIZE; - @param offset - physical offset within the file - @param block - block read from file, note it is not from the buffer pool - @retval DB_SUCCESS or error code. */ - virtual dberr_t operator()( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW = 0; - - /** - Set the name of the physical file and the file handle that is used - to open it for the file that is being iterated over. - @param filename - then physical name of the tablespace file. - @param file - OS file handle */ - void set_file(const char* filename, pfs_os_file_t file) UNIV_NOTHROW - { - m_file = file; - m_filepath = filename; - } - - /** - @return the space id of the tablespace */ - virtual ulint get_space_id() const UNIV_NOTHROW = 0; - - /** The compressed page size - @return the compressed page size */ - ulint get_zip_size() const - { - return(m_zip_size); - } - - /** - Set the tablespace compressed table size. - @return DB_SUCCESS if it is valie or DB_CORRUPTION if not */ - dberr_t set_zip_size(const buf_frame_t* page) UNIV_NOTHROW; - - /** The compressed page size - @return the compressed page size */ - ulint get_page_size() const - { - return(m_page_size); - } - - /** Compressed table page size */ - ulint m_zip_size; - - /** The tablespace page size. */ - ulint m_page_size; - - /** File handle to the tablespace */ - pfs_os_file_t m_file; - - /** Physical file path. */ - const char* m_filepath; - -protected: - // Disable copying - PageCallback(const PageCallback&); - PageCallback& operator=(const PageCallback&); -}; - -/********************************************************************//** -Iterate over all the pages in the tablespace. -@param table - the table definiton in the server -@param n_io_buffers - number of blocks to read and write together -@param callback - functor that will do the page updates -@return DB_SUCCESS or error code */ -UNIV_INTERN -dberr_t -fil_tablespace_iterate( -/*===================*/ - dict_table_t* table, - ulint n_io_buffers, - PageCallback& callback) - MY_ATTRIBUTE((nonnull, warn_unused_result)); - /*******************************************************************//** Checks if a single-table tablespace for a given table name exists in the tablespace memory cache. diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index 6c2504c9f8c0423c4c8154f90c81211cd4eb81e7..3f21c5293081e17e044f2a0be11676a3c286c306 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, 2017, MariaDB Corporation. +Copyright (c) 2015, 2018, 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 @@ -65,12 +65,9 @@ fil_get_page_type_name( return "ZBLOB"; case FIL_PAGE_TYPE_ZBLOB2: return "ZBLOB2"; - case FIL_PAGE_TYPE_COMPRESSED: - return "ORACLE PAGE COMPRESSED"; } return "PAGE TYPE CORRUPTED"; - } /****************************************************************//** @@ -112,8 +109,7 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_XDES || page_type == FIL_PAGE_TYPE_BLOB || page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_TYPE_ZBLOB2 || - page_type == FIL_PAGE_TYPE_COMPRESSED))) { + page_type == FIL_PAGE_TYPE_ZBLOB2))) { ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h index 03e16699ce383e3f21c02ef716e4a6462aaea4ab..934372c55b2a45169f07b4e0d11d21ab37aac309 100644 --- a/storage/innobase/include/fil0pagecompress.h +++ b/storage/innobase/include/fil0pagecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017 MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018 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 @@ -30,70 +30,26 @@ atomic writes information to table space. Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com ***********************************************************************/ -/*******************************************************************//** -Find out wheather the page is index page or not -@return true if page type index page, false if not */ -UNIV_INLINE -ibool -fil_page_is_index_page( -/*===================*/ - byte *buf); /*!< in: page */ - -/****************************************************************//** -Get the name of the compression algorithm used for page -compression. -@return compression algorithm name or "UNKNOWN" if not known*/ -UNIV_INLINE -const char* -fil_get_compression_alg_name( -/*=========================*/ - ulint comp_alg); /*!mutex and sometimes by trx->mutex. */ -typedef enum { +enum trx_abort_t { TRX_SERVER_ABORT = 0, - TRX_WSREP_ABORT = 1, - TRX_REPLICATION_ABORT = 2 -} trx_abort_t; +#ifdef WITH_WSREP + TRX_WSREP_ABORT, +#endif + TRX_REPLICATION_ABORT +}; struct trx_t{ ulint magic_n; diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 24bcab56870dc8406efe48234e27db8405164f46..7304d1e5d87db97e2c4a84f512719288e8054e05 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 37 +#define INNODB_VERSION_BUGFIX 40 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; @@ -65,6 +65,10 @@ component, i.e. we show M.N.P as M.N */ IB_TO_STR(INNODB_VERSION_MAJOR) "." \ IB_TO_STR(INNODB_VERSION_MINOR) "/en/" +/** How far ahead should we tell the service manager the timeout +(time in seconds) */ +#define INNODB_EXTEND_TIMEOUT_INTERVAL 30 + #ifdef MYSQL_DYNAMIC_PLUGIN /* In the dynamic plugin, redefine some externally visible symbols in order not to conflict with the symbols of a builtin InnoDB. */ diff --git a/storage/innobase/include/ut0timer.h b/storage/innobase/include/ut0timer.h index f361ae79bf525f6784ddffff7c4ee3523fdc25fc..3015771b434d7268f7258155fbb7ef4e18041383 100644 --- a/storage/innobase/include/ut0timer.h +++ b/storage/innobase/include/ut0timer.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. -Copyright (c) 2014, SkySQL Ab. All Rights Reserved. +Copyright (c) 2014, 2018, 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 @@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc., /********************************************************************//** @file include/ut0timer.h -Timer rountines +Timer routines Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 @@ -28,8 +28,6 @@ modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11 #define ut0timer_h #include "univ.i" -#include "data0type.h" -#include /* Current timer stats */ extern struct my_timer_unit_info ut_timer; @@ -47,39 +45,6 @@ Initializes my_timer struct to contain the info for selected timer.*/ UNIV_INTERN void ut_init_timer(void); -/**************************************************************//** -Return time passed since time then, automatically adjusted -for the estimated timer overhead. -@return time passed since "then" */ -UNIV_INLINE -ulonglong -ut_timer_since( -/*===========*/ - ulonglong then); /*!< in: time where to calculate */ -/**************************************************************//** -Get time passed since "then", and update then to now -@return time passed sinche "then" */ -UNIV_INLINE -ulonglong -ut_timer_since_and_update( -/*======================*/ - ulonglong *then); /*!< in: time where to calculate */ -/**************************************************************//** -Convert native timer units in a ulonglong into seconds in a double -@return time in a seconds */ -UNIV_INLINE -double -ut_timer_to_seconds( -/*=================*/ - ulonglong when); /*!< in: time where to calculate */ -/**************************************************************//** -Convert native timer units in a ulonglong into milliseconds in a double -@return time in milliseconds */ -UNIV_INLINE -double -ut_timer_to_milliseconds( -/*=====================*/ - ulonglong when); /*!< in: time where to calculate */ /**************************************************************//** Convert native timer units in a ulonglong into microseconds in a double @return time in microseconds */ diff --git a/storage/innobase/include/ut0timer.ic b/storage/innobase/include/ut0timer.ic index 46dcd0cb71834ed743720b5cae4f4c899fb9cce9..34886481efab3b339519ce724180c8cbe9e0d6ba 100644 --- a/storage/innobase/include/ut0timer.ic +++ b/storage/innobase/include/ut0timer.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. -Copyright (c) 2014, SkySQL Ab. All Rights Reserved. +Copyright (c) 2014, 2018, 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 @@ -19,69 +19,12 @@ this program; if not, write to the Free Software Foundation, Inc., /********************************************************************//** @file include/ut0timer.ic -Timer rountines +Timer routines Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 *************************************************************************/ -/**************************************************************//** -Return time passed since time then, automatically adjusted -for the estimated timer overhead. -@return time passed since "then" */ -UNIV_INLINE -ulonglong -ut_timer_since( -/*===========*/ - ulonglong then) /*!< in: time where to calculate */ -{ - return (ut_timer_now() - then) - ut_timer.overhead; -} - -/**************************************************************//** -Get time passed since "then", and update then to now -@return time passed sinche "then" */ -UNIV_INLINE -ulonglong -ut_timer_since_and_update( -/*======================*/ - ulonglong *then) /*!< in: time where to calculate */ -{ - ulonglong now = ut_timer_now(); - ulonglong ret = (now - (*then)) - ut_timer.overhead; - *then = now; - return ret; -} - -/**************************************************************//** -Convert native timer units in a ulonglong into seconds in a double -@return time in a seconds */ -UNIV_INLINE -double -ut_timer_to_seconds( -/*=================*/ - ulonglong when) /*!< in: time where to calculate */ -{ - double ret = (double)(when); - ret /= (double)(ut_timer.frequency); - return ret; -} - -/**************************************************************//** -Convert native timer units in a ulonglong into milliseconds in a double -@return time in milliseconds */ -UNIV_INLINE -double -ut_timer_to_milliseconds( -/*=====================*/ - ulonglong when) /*!< in: time where to calculate */ -{ - double ret = (double)(when); - ret *= 1000.0; - ret /= (double)(ut_timer.frequency); - return ret; -} - /**************************************************************//** Convert native timer units in a ulonglong into microseconds in a double @return time in microseconds */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 64e7a8b96adb0aa1c9798fe7c53b971530327550..441fcace7c3de8630d6381e8a93729ccc6f90121 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -898,7 +898,7 @@ UNIV_INLINE void lock_reset_lock_and_trx_wait( /*=========================*/ - lock_t* lock) /*!< in/out: record lock */ + lock_t* lock) /*!< in/out: record lock */ { ut_ad(lock_get_wait(lock)); ut_ad(lock_mutex_own()); @@ -2216,13 +2216,6 @@ lock_rec_create( trx_mutex_enter(trx); } - /* trx might not wait for c_lock, but some other lock - does not matter if wait_lock was released above - */ - if (c_lock->trx->lock.wait_lock == c_lock) { - lock_reset_lock_and_trx_wait(lock); - } - trx_mutex_exit(c_lock->trx); if (wsrep_debug) { @@ -4970,19 +4963,18 @@ lock_table_create( UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); #ifdef WITH_WSREP - if (wsrep_thd_is_wsrep(trx->mysql_thd)) { - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock) { + if (wsrep_thd_is_wsrep(trx->mysql_thd) + && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { UT_LIST_INSERT_AFTER( un_member.tab_lock.locks, table->locks, c_lock, lock); } else { UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); } - if (c_lock) { - trx_mutex_enter(c_lock->trx); - } + trx_mutex_enter(c_lock->trx); - if (c_lock && c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { + if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE; @@ -4991,36 +4983,21 @@ lock_table_create( wsrep_print_wait_locks(c_lock->trx->lock.wait_lock); } - /* have to release trx mutex for the duration of - victim lock release. This will eventually call - lock_grant, which wants to grant trx mutex again - */ - /* caller has trx_mutex, have to release for lock cancel */ + /* The lock release will call lock_grant(), + which would acquire trx->mutex again. */ trx_mutex_exit(trx); lock_cancel_waiting_and_release(c_lock->trx->lock.wait_lock); trx_mutex_enter(trx); - /* trx might not wait for c_lock, but some other lock - does not matter if wait_lock was released above - */ - if (c_lock->trx->lock.wait_lock == c_lock) { - lock_reset_lock_and_trx_wait(lock); - } - if (wsrep_debug) { fprintf(stderr, "WSREP: c_lock canceled " TRX_ID_FMT "\n", c_lock->trx->id); } } - if (c_lock) { - trx_mutex_exit(c_lock->trx); - } - } else { + trx_mutex_exit(c_lock->trx); + } else #endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { @@ -6918,10 +6895,10 @@ lock_rec_block_validate( page_no, RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr); - - buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); - - ut_ad(lock_rec_validate_page(block)); + if (block) { + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + ut_ad(lock_rec_validate_page(block)); + } mtr_commit(&mtr); fil_space_release(space); @@ -7940,7 +7917,10 @@ lock_trx_release_locks( } mutex_exit(&trx_sys->mutex); } else { - ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); + ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) + || (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) + && trx->is_recovered + && !UT_LIST_GET_LEN(trx->lock.trx_locks))); } /* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY @@ -7997,26 +7977,19 @@ lock_trx_handle_wait( /*=================*/ trx_t* trx) /*!< in/out: trx lock state */ { - dberr_t err; - - lock_mutex_enter(); - - trx_mutex_enter(trx); + ut_ad(lock_mutex_own()); + ut_ad(trx_mutex_own(trx)); if (trx->lock.was_chosen_as_deadlock_victim) { - err = DB_DEADLOCK; - } else if (trx->lock.wait_lock != NULL) { - lock_cancel_waiting_and_release(trx->lock.wait_lock); - err = DB_LOCK_WAIT; - } else { + return DB_DEADLOCK; + } + if (!trx->lock.wait_lock) { /* The lock was probably granted before we got here. */ - err = DB_SUCCESS; + return DB_SUCCESS; } - lock_mutex_exit(); - trx_mutex_exit(trx); - - return(err); + lock_cancel_waiting_and_release(trx->lock.wait_lock); + return DB_LOCK_WAIT; } /*********************************************************************//** diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 7a242b76e854eb7d79d74fc8d55860975ad816e2..6546459354b4e555cb95c0c0892d19040546551c 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -39,7 +39,7 @@ Created 12/9/1995 Heikki Tuuri #ifndef UNIV_HOTBACKUP #if MYSQL_VERSION_ID < 100200 -# include /* sd_notifyf() */ +# include #endif #include "mem0mem.h" @@ -1443,6 +1443,12 @@ log_write_up_to( return; } + if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "log write up to: " LSN_PF, + lsn); + } + loop: ut_ad(++loop_count < 100); @@ -2351,8 +2357,9 @@ log_group_read_log_seg( if (recv_sys->report(ut_time())) { ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF, start_lsn); - sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF, - start_lsn); + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Read redo log up to LSN=" LSN_PF, + start_lsn); } if (start_lsn != end_lsn) { @@ -3237,7 +3244,9 @@ logs_empty_and_mark_files_at_shutdown(void) os_event_set(lock_sys->timeout_event); os_event_set(dict_stats_event); } - os_thread_sleep(100000); +#define COUNT_INTERVAL 600U +#define CHECK_INTERVAL 100000U + os_thread_sleep(CHECK_INTERVAL); count++; @@ -3249,7 +3258,11 @@ logs_empty_and_mark_files_at_shutdown(void) if (ulint total_trx = srv_was_started && !srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO ? trx_sys_any_active_transactions() : 0) { - if (srv_print_verbose_log && count > 600) { + if (srv_print_verbose_log && count > COUNT_INTERVAL) { + service_manager_extend_timeout( + COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for %lu active transactions to finish", + (ulong) total_trx); ib_logf(IB_LOG_LEVEL_INFO, "Waiting for %lu active transactions to finish", (ulong) total_trx); @@ -3284,7 +3297,10 @@ logs_empty_and_mark_files_at_shutdown(void) if (thread_name) { ut_ad(!srv_read_only_mode); wait_suspend_loop: - if (srv_print_verbose_log && count > 600) { + service_manager_extend_timeout( + COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for %s to exit", thread_name); + if (srv_print_verbose_log && count > COUNT_INTERVAL) { ib_logf(IB_LOG_LEVEL_INFO, "Waiting for %s to exit", thread_name); count = 0; @@ -3320,10 +3336,14 @@ logs_empty_and_mark_files_at_shutdown(void) before proceeding further. */ count = 0; + service_manager_extend_timeout(COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for page cleaner"); while (buf_page_cleaner_is_active) { ++count; - os_thread_sleep(100000); - if (srv_print_verbose_log && count > 600) { + os_thread_sleep(CHECK_INTERVAL); + if (srv_print_verbose_log && count > COUNT_INTERVAL) { + service_manager_extend_timeout(COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for page cleaner"); ib_logf(IB_LOG_LEVEL_INFO, "Waiting for page_cleaner to " "finish flushing of buffer pool"); @@ -3408,6 +3428,8 @@ logs_empty_and_mark_files_at_shutdown(void) } if (!srv_read_only_mode) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "ensuring dirty buffer pool are written to log"); log_make_checkpoint_at(LSN_MAX, TRUE); mutex_enter(&log_sys->mutex); @@ -3441,23 +3463,9 @@ logs_empty_and_mark_files_at_shutdown(void) mutex_exit(&log_sys->mutex); - fil_flush_file_spaces(FIL_TABLESPACE); + /* Ensure that all buffered changes are written to the + redo log before fil_close_all_files(). */ fil_flush_file_spaces(FIL_LOG); - - /* The call fil_write_flushed_lsn_to_data_files() will - bypass the buffer pool: therefore it is essential that - the buffer pool has been completely flushed to disk! */ - - if (!buf_all_freed()) { - if (srv_print_verbose_log && count > 600) { - ib_logf(IB_LOG_LEVEL_INFO, - "Waiting for dirty buffer pages" - " to be flushed"); - count = 0; - } - - goto loop; - } } else { lsn = srv_start_lsn; } @@ -3468,8 +3476,9 @@ logs_empty_and_mark_files_at_shutdown(void) srv_thread_type type = srv_get_active_thread_type(); ut_a(type == SRV_NONE); - bool freed = buf_all_freed(); - ut_a(freed); + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Free innodb buffer pool"); + buf_all_freed(); ut_a(lsn == log_sys->lsn); @@ -3499,9 +3508,6 @@ logs_empty_and_mark_files_at_shutdown(void) type = srv_get_active_thread_type(); ut_a(type == SRV_NONE); - freed = buf_all_freed(); - ut_a(freed); - ut_a(lsn == log_sys->lsn); } diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 6e6d8aae25e9d70bdeb594713463e6c45edeb19d..deaf5e88d7cb4d66d2ed30835360072ebfc2818b 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -30,7 +30,7 @@ Created 9/20/1997 Heikki Tuuri #include // Solaris/x86 header file bug #include -#include +#include #include "log0recv.h" @@ -1717,8 +1717,8 @@ recv_recover_page_func( if (recv_sys->report(time)) { ib_logf(IB_LOG_LEVEL_INFO, "To recover: " ULINTPF " pages from log", n); - sd_notifyf(0, "STATUS=To recover: " ULINTPF - " pages from log", n); + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, "To recover: " ULINTPF " pages from log", n); } } @@ -2911,6 +2911,9 @@ recv_init_crash_recovery(void) and restore them from the doublewrite buffer if possible */ + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, "Starting Innodb crash recovery"); + if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { buf_dblwr_process(); diff --git a/storage/innobase/mem/mem0mem.cc b/storage/innobase/mem/mem0mem.cc index b9f190509eebb549a5e9c3302be21928990953de..f91126697fc71683a12a1b7145a577355037aab7 100644 --- a/storage/innobase/mem/mem0mem.cc +++ b/storage/innobase/mem/mem0mem.cc @@ -406,6 +406,11 @@ mem_heap_create_block_func( heap->total_size += len; } + /* Poison all available memory. Individual chunks will be unpoisoned on + every mem_heap_alloc() call. */ + compile_time_assert(MEM_BLOCK_HEADER_SIZE >= sizeof *block); + UNIV_MEM_FREE(block + 1, len - sizeof *block); + ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len); return(block); diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index e9abdc91ff8807152f030b25f83dc2de093ad61d..5aa9b6040f89abc1504b5d99d5c7f1809f993d6f 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -1350,7 +1350,8 @@ os_file_create_simple_func( /* Use default security attributes and no template file. */ file = CreateFile( - (LPCTSTR) name, access, FILE_SHARE_READ, NULL, + (LPCTSTR) name, access, + FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, create_flag, attributes, NULL); if (file == INVALID_HANDLE_VALUE) { @@ -1421,7 +1422,7 @@ os_file_create_simple_func( } do { - file = ::open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC, os_innodb_umask); if (file == -1) { *success = FALSE; @@ -1483,7 +1484,7 @@ os_file_create_simple_no_error_handling_func( DWORD access; DWORD create_flag; DWORD attributes = 0; - DWORD share_mode = FILE_SHARE_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE; ut_a(name); ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); @@ -1604,7 +1605,7 @@ os_file_create_simple_no_error_handling_func( return(file); } - file = open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC, os_innodb_umask); *success = file != -1; @@ -1764,7 +1765,7 @@ os_file_create_func( #ifdef __WIN__ DWORD create_flag; - DWORD share_mode = FILE_SHARE_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE; on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT ? TRUE : FALSE; @@ -1969,7 +1970,7 @@ os_file_create_func( #endif /* O_SYNC */ do { - file = open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC, os_innodb_umask); if (file == -1) { const char* operation; @@ -2184,6 +2185,24 @@ os_file_delete_func( #endif } +/** Handle RENAME error. +@param name old name of the file +@param new_name new name of the file */ +static void os_file_handle_rename_error(const char* name, const char* new_name) +{ + if (os_file_get_last_error(true) != OS_FILE_DISK_FULL) { + ib_logf(IB_LOG_LEVEL_ERROR, "Cannot rename file '%s' to '%s'", + name, new_name); + } else if (!os_has_said_disk_full) { + os_has_said_disk_full = true; + /* Disk full error is reported irrespective of the + on_error_silent setting. */ + ib_logf(IB_LOG_LEVEL_ERROR, + "Full disk prevents renaming file '%s' to '%s'", + name, new_name); + } +} + /***********************************************************************//** NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can also move it to another directory). It is safest that the @@ -2219,8 +2238,7 @@ os_file_rename_func( return(TRUE); } - os_file_handle_error_no_exit(oldpath, "rename", FALSE, __FILE__, __LINE__); - + os_file_handle_rename_error(oldpath, newpath); return(FALSE); #else int ret; @@ -2229,8 +2247,7 @@ os_file_rename_func( ret = rename(oldpath, newpath); if (ret != 0) { - os_file_handle_error_no_exit(oldpath, "rename", FALSE, __FILE__, __LINE__); - + os_file_handle_rename_error(oldpath, newpath); return(FALSE); } @@ -2842,8 +2859,15 @@ os_file_read_func( MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); - if (ret && len == n) { + if (!ret) { + } else if (len == n) { return(TRUE); + } else { + ib_logf(IB_LOG_LEVEL_ERROR, + "Tried to read " ULINTPF " bytes at offset " + UINT64PF ". Was only able to read %lu.", + n, offset, ret); + return FALSE; } #else /* __WIN__ */ ibool retry; @@ -2866,6 +2890,7 @@ os_file_read_func( "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", n, offset, (lint) ret); + return FALSE; } #endif /* __WIN__ */ #ifdef __WIN__ @@ -2964,8 +2989,15 @@ os_file_read_no_error_handling_func( MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); - if (ret && len == n) { + if (!ret) { + } else if (len == n) { return(TRUE); + } else { + ib_logf(IB_LOG_LEVEL_ERROR, + "Tried to read " ULINTPF " bytes at offset " + UINT64PF ". Was only able to read %lu.", + n, offset, len); + return FALSE; } #else /* __WIN__ */ ibool retry; @@ -2988,6 +3020,7 @@ os_file_read_no_error_handling_func( "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", n, offset, (lint) ret); + return FALSE; } #endif /* __WIN__ */ #ifdef __WIN__ @@ -3422,7 +3455,7 @@ os_file_get_status( access = !srv_read_only_mode ? O_RDWR : O_RDONLY; - fh = ::open(path, access, os_innodb_umask); + fh = ::open(path, access | O_CLOEXEC, os_innodb_umask); if (fh == -1) { stat_info->rw_perm = false; @@ -3851,7 +3884,7 @@ os_aio_native_aio_supported(void) strcpy(name + dirnamelen, "ib_logfile0"); - fd = ::open(name, O_RDONLY); + fd = ::open(name, O_RDONLY | O_CLOEXEC); if (fd == -1) { diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index 231c0101266a04b31da0d130532f724aa4732ee2..2cc967129a93ed608b7a6ff8d3d87a534ffd53f9 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2,6 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2018, 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 @@ -93,17 +94,13 @@ page_dir_find_owner_slot( /*=====================*/ const rec_t* rec) /*!< in: the physical record */ { - const page_t* page; - register uint16 rec_offs_bytes; - register const page_dir_slot_t* slot; - register const page_dir_slot_t* first_slot; - register const rec_t* r = rec; - ut_ad(page_rec_check(rec)); - page = page_align(rec); - first_slot = page_dir_get_nth_slot(page, 0); - slot = page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1); + const page_t* page = page_align(rec); + const page_dir_slot_t* first_slot = page_dir_get_nth_slot(page, 0); + const page_dir_slot_t* slot = page_dir_get_nth_slot( + page, page_dir_get_n_slots(page) - 1); + const rec_t* r = rec; if (page_is_comp(page)) { while (rec_get_n_owned_new(r) == 0) { @@ -119,7 +116,7 @@ page_dir_find_owner_slot( } } - rec_offs_bytes = mach_encode_2(r - page); + uint16 rec_offs_bytes = mach_encode_2(r - page); while (UNIV_LIKELY(*(uint16*) slot != rec_offs_bytes)) { diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index cc5fe0acf926d4381dccbafd9ea8455e135241c3..c808a991f25afb89a9d81dbf2c17b08cc6e951e9 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -31,6 +31,7 @@ Created 2012-02-08 by Sunny Bains. #endif #include "btr0pcur.h" +#include "btr0sea.h" #include "que0que.h" #include "dict0boot.h" #include "ibuf0ibuf.h" @@ -40,12 +41,17 @@ Created 2012-02-08 by Sunny Bains. #include "row0mysql.h" #include "srv0start.h" #include "row0quiesce.h" +#include "fil0pagecompress.h" +#ifdef HAVE_LZO +#include "lzo/lzo1x.h" +#endif +#ifdef HAVE_SNAPPY +#include "snappy-c.h" +#endif #include -/** The size of the buffer to use for IO. Note: os_file_read() doesn't expect -reads to fail. If you set the buffer size to be greater than a multiple of the -file size then it will assert. TODO: Fix this limitation of the IO functions. +/** The size of the buffer to use for IO. @param n - page size of the tablespace. @retval number of pages */ #define IO_BUFFER_SIZE(n) ((1024 * 1024) / n) @@ -361,7 +367,8 @@ class IndexPurge { /** Functor that is called for each physical page that is read from the tablespace file. */ -class AbstractCallback : public PageCallback { +class AbstractCallback +{ public: /** Constructor @param trx - covering transaction */ @@ -394,32 +401,59 @@ class AbstractCallback : public PageCallback { return(get_zip_size() > 0); } -protected: /** - Get the data page depending on the table type, compressed or not. - @param block - block read from disk - @retval the buffer frame */ - buf_frame_t* get_frame(buf_block_t* block) const UNIV_NOTHROW + Set the name of the physical file and the file handle that is used + to open it for the file that is being iterated over. + @param filename - then physical name of the tablespace file. + @param file - OS file handle */ + void set_file(const char* filename, pfs_os_file_t file) UNIV_NOTHROW { - if (is_compressed_table()) { - return(block->page.zip.data); - } + m_file = file; + m_filepath = filename; + } - return(buf_block_get_frame(block)); + /** The compressed page size + @return the compressed page size */ + ulint get_zip_size() const + { + return(m_zip_size); } - /** Check for session interrupt. If required we could - even flush to disk here every N pages. - @retval DB_SUCCESS or error code */ - dberr_t periodic_check() UNIV_NOTHROW + /** The compressed page size + @return the compressed page size */ + ulint get_page_size() const { - if (trx_is_interrupted(m_trx)) { - return(DB_INTERRUPTED); - } + return(m_page_size); + } - return(DB_SUCCESS); + const char* filename() const { return m_filepath; } + + /** + Called for every page in the tablespace. If the page was not + updated then its state must be set to BUF_PAGE_NOT_USED. For + compressed tables the page descriptor memory will be at offset: + block->frame + UNIV_PAGE_SIZE; + @param block block read from file, note it is not from the buffer pool + @retval DB_SUCCESS or error code. */ + virtual dberr_t operator()(buf_block_t* block) UNIV_NOTHROW = 0; + + /** + @return the space id of the tablespace */ + virtual ulint get_space_id() const UNIV_NOTHROW = 0; + + bool is_interrupted() const { return trx_is_interrupted(m_trx); } + + /** + Get the data page depending on the table type, compressed or not. + @param block - block read from disk + @retval the buffer frame */ + static byte* get_frame(const buf_block_t* block) + { + return block->page.zip.data + ? block->page.zip.data : block->frame; } +protected: /** Get the physical offset of the extent descriptor within the page. @param page_no - page number of the extent descriptor @@ -509,6 +543,18 @@ class AbstractCallback : public PageCallback { } protected: + /** Compressed table page size */ + ulint m_zip_size; + + /** The tablespace page size. */ + ulint m_page_size; + + /** File handle to the tablespace */ + pfs_os_file_t m_file; + + /** Physical file path. */ + const char* m_filepath; + /** Covering transaction. */ trx_t* m_trx; @@ -565,9 +611,9 @@ AbstractCallback::init( /* Since we don't know whether it is a compressed table or not, the data is always read into the block->frame. */ - dberr_t err = set_zip_size(block->frame); + m_zip_size = fsp_header_get_zip_size(page); - if (err != DB_SUCCESS) { + if (!ut_is_2pow(m_zip_size) || m_zip_size > UNIV_ZIP_SIZE_MAX) { return(DB_CORRUPTION); } @@ -604,11 +650,7 @@ AbstractCallback::init( m_free_limit = mach_read_from_4(page + FSP_FREE_LIMIT); m_space = mach_read_from_4(page + FSP_HEADER_OFFSET + FSP_SPACE_ID); - if ((err = set_current_xdes(0, page)) != DB_SUCCESS) { - return(err); - } - - return(DB_SUCCESS); + return set_current_xdes(0, page); } /** @@ -650,12 +692,9 @@ struct FetchIndexRootPages : public AbstractCallback { /** Called for each block as it is read from the file. - @param offset - physical offset in the file - @param block - block to convert, it is not from the buffer pool. + @param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ - virtual dberr_t operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW; + dberr_t operator()(buf_block_t* block) UNIV_NOTHROW; /** Update the import configuration that will be used to import the tablespace. */ @@ -673,34 +712,18 @@ Called for each block as it is read from the file. Check index pages to determine the exact row format. We can't get that from the tablespace header flags alone. -@param offset - physical offset in the file -@param block - block to convert, it is not from the buffer pool. +@param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ -dberr_t -FetchIndexRootPages::operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW +dberr_t FetchIndexRootPages::operator()(buf_block_t* block) UNIV_NOTHROW { - dberr_t err; - - if ((err = periodic_check()) != DB_SUCCESS) { - return(err); - } + if (is_interrupted()) return DB_INTERRUPTED; const page_t* page = get_frame(block); ulint page_type = fil_page_get_type(page); - if (block->page.offset * m_page_size != offset) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Page offset doesn't match file offset: " - "page offset: %u, file offset: " ULINTPF, - block->page.offset, - (ulint) (offset / m_page_size)); - - err = DB_CORRUPTION; - } else if (page_type == FIL_PAGE_TYPE_XDES) { - err = set_current_xdes(block->page.offset, page); + if (page_type == FIL_PAGE_TYPE_XDES) { + return set_current_xdes(block->page.offset, page); } else if (page_type == FIL_PAGE_INDEX && !is_free(block->page.offset) && is_root_page(page)) { @@ -725,7 +748,7 @@ FetchIndexRootPages::operator() ( } } - return(err); + return DB_SUCCESS; } /** @@ -842,21 +865,10 @@ class PageConverter : public AbstractCallback { /** Called for each block as it is read from the file. - @param offset - physical offset in the file - @param block - block to convert, it is not from the buffer pool. + @param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ - virtual dberr_t operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW; + dberr_t operator()(buf_block_t* block) UNIV_NOTHROW; private: - - /** Status returned by PageConverter::validate() */ - enum import_page_status_t { - IMPORT_PAGE_STATUS_OK, /*!< Page is OK */ - IMPORT_PAGE_STATUS_ALL_ZERO, /*!< Page is all zeros */ - IMPORT_PAGE_STATUS_CORRUPTED /*!< Page is corrupted */ - }; - /** Update the page, set the space id, max trx id and index id. @param block - block read from file @@ -866,17 +878,6 @@ class PageConverter : public AbstractCallback { buf_block_t* block, ulint& page_type) UNIV_NOTHROW; -#if defined UNIV_DEBUG - /** - @return true error condition is enabled. */ - bool trigger_corruption() UNIV_NOTHROW - { - return(false); - } - #else -#define trigger_corruption() (false) -#endif /* UNIV_DEBUG */ - /** Update the space, index id, trx id. @param block - block to convert @@ -889,15 +890,6 @@ class PageConverter : public AbstractCallback { @retval DB_SUCCESS or error code */ dberr_t update_records(buf_block_t* block) UNIV_NOTHROW; - /** - Validate the page, check for corruption. - @param offset - physical offset within file. - @param page - page read from file. - @return 0 on success, 1 if all zero, 2 if corrupted */ - import_page_status_t validate( - os_offset_t offset, - buf_block_t* page) UNIV_NOTHROW; - /** Validate the space flags and update tablespace header page. @param block - block read from file, not from the buffer pool. @@ -1596,6 +1588,7 @@ IndexPurge::purge() UNIV_NOTHROW Constructor * @param cfg - config of table being imported. * @param trx - transaction covering the import */ +inline PageConverter::PageConverter( row_import* cfg, trx_t* trx) @@ -1620,6 +1613,7 @@ Adjust the BLOB reference for a single column that is externally stored @param offsets - column offsets for the record @param i - column ordinal value @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_column( rec_t* rec, @@ -1672,6 +1666,7 @@ stored columns. @param rec - record to update @param offsets - column offsets for the record @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_columns( rec_t* rec, @@ -1705,6 +1700,7 @@ BLOB reference, write the new space id. @param rec - record to update @param offsets - column offsets for the record @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_ref( rec_t* rec, @@ -1728,6 +1724,7 @@ Purge delete-marked records, only if it is possible to do so without re-organising the B+tree. @param offsets - current row offsets. @return true if purge succeeded */ +inline bool PageConverter::purge(const ulint* offsets) UNIV_NOTHROW { @@ -1752,6 +1749,7 @@ Adjust the BLOB references and sys fields for the current record. @param offsets - column offsets for the record @param deleted - true if row is delete marked @return DB_SUCCESS or error code. */ +inline dberr_t PageConverter::adjust_cluster_record( const dict_index_t* index, @@ -1769,7 +1767,7 @@ PageConverter::adjust_cluster_record( row_upd_rec_sys_fields( rec, m_page_zip_ptr, m_cluster_index, m_offsets, - m_trx, 0); + m_trx, roll_ptr_t(1) << 55); } return(err); @@ -1780,6 +1778,7 @@ Update the BLOB refrences and write UNDO log entries for rows that can't be purged optimistically. @param block - block to update @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_records( buf_block_t* block) UNIV_NOTHROW @@ -1791,12 +1790,9 @@ PageConverter::update_records( m_rec_iter.open(block); - if (!page_is_leaf(block->frame)) { - return DB_SUCCESS; - } - while (!m_rec_iter.end()) { rec_t* rec = m_rec_iter.current(); + ibool deleted = rec_get_deleted_flag(rec, comp); /* For the clustered index we have to adjust the BLOB @@ -1845,6 +1841,7 @@ PageConverter::update_records( /** Update the space, index id, trx id. @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_index_page( buf_block_t* block) UNIV_NOTHROW @@ -1907,13 +1904,14 @@ PageConverter::update_index_page( return(DB_SUCCESS); } - return(update_records(block)); + return page_is_leaf(block->frame) ? update_records(block) : DB_SUCCESS; } /** Validate the space flags and update tablespace header page. @param block - block read from file, not from the buffer pool. @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_header( buf_block_t* block) UNIV_NOTHROW @@ -1953,6 +1951,7 @@ PageConverter::update_header( Update the page, set the space id, max trx id and index id. @param block - block read from file @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_page( buf_block_t* block, @@ -1960,6 +1959,14 @@ PageConverter::update_page( { dberr_t err = DB_SUCCESS; + ut_ad(!block->page.zip.data == !is_compressed_table()); + + if (block->page.zip.data) { + m_page_zip_ptr = &block->page.zip; + } else { + ut_ad(!m_page_zip_ptr); + } + switch (page_type = fil_page_get_type(get_frame(block))) { case FIL_PAGE_TYPE_FSP_HDR: /* Work directly on the uncompressed page headers. */ @@ -2014,141 +2021,45 @@ PageConverter::update_page( return(DB_CORRUPTION); } -/** -Validate the page -@param offset - physical offset within file. -@param page - page read from file. -@return status */ -PageConverter::import_page_status_t -PageConverter::validate( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW -{ - buf_frame_t* page = get_frame(block); - - /* Check that the page number corresponds to the offset in - the file. Flag as corrupt if it doesn't. Disable the check - for LSN in buf_page_is_corrupted() */ - - if (buf_page_is_corrupted(false, page, get_zip_size(), NULL) - || (page_get_page_no(page) != offset / m_page_size - && page_get_page_no(page) != 0)) { - - return(IMPORT_PAGE_STATUS_CORRUPTED); - - } else if (offset > 0 && page_get_page_no(page) == 0) { - ulint checksum; - - checksum = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM); - if (checksum != 0) { - /* Checksum check passed in buf_page_is_corrupted(). */ - ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu checksum " ULINTPF - " should be zero.", - m_filepath, (ulong) (offset / m_page_size), - checksum); - } - - const byte* b = page + FIL_PAGE_OFFSET; - const byte* e = page + m_page_size - - FIL_PAGE_END_LSN_OLD_CHKSUM; - - /* If the page number is zero and offset > 0 then - the entire page MUST consist of zeroes. If not then - we flag it as corrupt. */ - - while (b != e) { - - if (*b++ && !trigger_corruption()) { - return(IMPORT_PAGE_STATUS_CORRUPTED); - } - } - - /* The page is all zero: do nothing. */ - return(IMPORT_PAGE_STATUS_ALL_ZERO); - } - - return(IMPORT_PAGE_STATUS_OK); -} - /** Called for every page in the tablespace. If the page was not updated then its state must be set to BUF_PAGE_NOT_USED. -@param offset - physical offset within the file -@param block - block read from file, note it is not from the buffer pool +@param block block read from file, note it is not from the buffer pool @retval DB_SUCCESS or error code. */ -dberr_t -PageConverter::operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW +dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW { - ulint page_type; - dberr_t err = DB_SUCCESS; - - if ((err = periodic_check()) != DB_SUCCESS) { - return(err); - } - - if (is_compressed_table()) { - m_page_zip_ptr = &block->page.zip; - } else { - ut_ad(m_page_zip_ptr == 0); - } - - switch(validate(offset, block)) { - case IMPORT_PAGE_STATUS_OK: - - /* We have to decompress the compressed pages before - we can work on them */ - - if ((err = update_page(block, page_type)) != DB_SUCCESS) { - break; - } - - /* Note: For compressed pages this function will write to the - zip descriptor and for uncompressed pages it will write to - page (ie. the block->frame). Therefore the caller should write - out the descriptor contents and not block->frame for compressed - pages. */ - - if (!is_compressed_table() || page_type == FIL_PAGE_INDEX) { - - buf_flush_init_for_writing( - !is_compressed_table() - ? block->frame : block->page.zip.data, - !is_compressed_table() ? 0 : m_page_zip_ptr, - m_current_lsn); - } else { - /* Calculate and update the checksum of non-btree - pages for compressed tables explicitly here. */ - - buf_flush_update_zip_checksum( - get_frame(block), get_zip_size(), - m_current_lsn); - } - - break; + /* If we already had an old page with matching number + in the buffer pool, evict it now, because + we no longer evict the pages on DISCARD TABLESPACE. */ + buf_page_get_gen(get_space_id(), get_zip_size(), block->page.offset, + RW_NO_LATCH, NULL, BUF_EVICT_IF_IN_POOL, + __FILE__, __LINE__, NULL); - case IMPORT_PAGE_STATUS_ALL_ZERO: - /* The page is all zero: leave it as is. */ - break; + ulint page_type; - case IMPORT_PAGE_STATUS_CORRUPTED: + dberr_t err = update_page(block, page_type); + if (err != DB_SUCCESS) return err; - ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu at offset " UINT64PF " looks corrupted.", - m_filepath, (ulong) (offset / m_page_size), offset); + /* Note: For compressed pages this function will write to the + zip descriptor and for uncompressed pages it will write to + page (ie. the block->frame). Therefore the caller should write + out the descriptor contents and not block->frame for compressed + pages. */ - err = DB_CORRUPTION; + if (!is_compressed_table() || page_type == FIL_PAGE_INDEX) { + buf_flush_init_for_writing( + get_frame(block), + block->page.zip.data ? &block->page.zip : NULL, + m_current_lsn); + } else { + /* Calculate and update the checksum of non-btree + pages for compressed tables explicitly here. */ + buf_flush_update_zip_checksum( + get_frame(block), get_zip_size(), + m_current_lsn); } - /* If we already had and old page with matching number - in the buffer pool, evict it now, because - we no longer evict the pages on DISCARD TABLESPACE. */ - buf_page_get_gen(get_space_id(), get_zip_size(), block->page.offset, - RW_NO_LATCH, NULL, BUF_EVICT_IF_IN_POOL, - __FILE__, __LINE__, NULL); - return(err); + return DB_SUCCESS; } /*****************************************************************//** @@ -3423,6 +3334,498 @@ row_import_update_discarded_flag( return(err); } +struct fil_iterator_t { + pfs_os_file_t file; /*!< File handle */ + const char* filepath; /*!< File path name */ + os_offset_t start; /*!< From where to start */ + os_offset_t end; /*!< Where to stop */ + os_offset_t file_size; /*!< File size in bytes */ + ulint page_size; /*!< Page size */ + ulint n_io_buffers; /*!< Number of pages to use + for IO */ + byte* io_buffer; /*!< Buffer to use for IO */ + fil_space_crypt_t *crypt_data; /*!< Crypt data (if encrypted) */ + byte* crypt_io_buffer; /*!< IO buffer when encrypted */ +}; + +/********************************************************************//** +TODO: This can be made parallel trivially by chunking up the file and creating +a callback per thread. . Main benefit will be to use multiple CPUs for +checksums and compressed tables. We have to do compressed tables block by +block right now. Secondly we need to decompress/compress and copy too much +of data. These are CPU intensive. + +Iterate over all the pages in the tablespace. +@param iter - Tablespace iterator +@param block - block to use for IO +@param callback - Callback to inspect and update page contents +@retval DB_SUCCESS or error code */ +static +dberr_t +fil_iterate( +/*========*/ + const fil_iterator_t& iter, + buf_block_t* block, + AbstractCallback& callback) +{ + os_offset_t offset; + ulint n_bytes = iter.n_io_buffers * iter.page_size; + + const ulint buf_size = srv_page_size +#ifdef HAVE_LZO + + LZO1X_1_15_MEM_COMPRESS +#elif defined HAVE_SNAPPY + + snappy_max_compressed_length(srv_page_size) +#endif + ; + byte* page_compress_buf = static_cast( + ut_malloc_low(buf_size, false)); + ut_ad(!srv_read_only_mode); + + if (!page_compress_buf) { + return DB_OUT_OF_MEMORY; + } + + /* TODO: For ROW_FORMAT=COMPRESSED tables we do a lot of useless + copying for non-index pages. Unfortunately, it is + required by buf_zip_decompress() */ + dberr_t err = DB_SUCCESS; + + for (offset = iter.start; offset < iter.end; offset += n_bytes) { + if (callback.is_interrupted()) { + err = DB_INTERRUPTED; + goto func_exit; + } + + byte* io_buffer = iter.io_buffer; + block->frame = io_buffer; + + if (block->page.zip.data) { + /* Zip IO is done in the compressed page buffer. */ + io_buffer = block->page.zip.data; + ut_ad(PAGE_ZIP_MATCH(block->frame, &block->page.zip)); + } + + /* We have to read the exact number of bytes. Otherwise the + InnoDB IO functions croak on failed reads. */ + + n_bytes = ulint(ut_min(os_offset_t(n_bytes), + iter.end - offset)); + + ut_ad(n_bytes > 0); + ut_ad(!(n_bytes % iter.page_size)); + + const bool encrypted = iter.crypt_data != NULL + && iter.crypt_data->should_encrypt(); + /* Use additional crypt io buffer if tablespace is encrypted */ + byte* const readptr = encrypted + ? iter.crypt_io_buffer : io_buffer; + byte* const writeptr = readptr; + + if (!os_file_read_no_error_handling(iter.file, readptr, + offset, n_bytes)) { + ib_logf(IB_LOG_LEVEL_ERROR, "os_file_read() failed"); + err = DB_IO_ERROR; + goto func_exit; + } + + bool updated = false; + const ulint size = iter.page_size; + ulint n_pages_read = ulint(n_bytes) / size; + block->page.offset = offset / size; + + for (ulint i = 0; i < n_pages_read; + ++i, block->frame += size, block->page.offset++) { + byte* src = readptr + (i * size); + const ulint page_no = page_get_page_no(src); + if (!page_no && block->page.offset) { + const ulint* b = reinterpret_cast + (src); + const ulint* const e = b + size / sizeof *b; + do { + if (*b++) { + goto page_corrupted; + } + } while (b != e); + + /* Proceed to the next page, + because this one is all zero. */ + continue; + } + + if (page_no != block->page.offset) { +page_corrupted: + ib_logf(IB_LOG_LEVEL_WARN, + "%s: Page %lu at offset " + UINT64PF " looks corrupted.", + callback.filename(), + ulong(offset / size), offset); + err = DB_CORRUPTION; + goto func_exit; + } + + bool decrypted = false; + byte* dst = io_buffer + (i * size); + bool frame_changed = false; + ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); + const bool page_compressed + = page_type + == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED + || page_type == FIL_PAGE_PAGE_COMPRESSED; + + if (page_compressed && block->page.zip.data) { + goto page_corrupted; + } + + if (!encrypted) { + } else if (!mach_read_from_4( + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + + src)) { +not_encrypted: + if (!page_compressed + && !block->page.zip.data) { + block->frame = src; + frame_changed = true; + } else { + ut_ad(dst != src); + memcpy(dst, src, size); + } + } else { + if (!fil_space_verify_crypt_checksum( + src, callback.get_zip_size(), + NULL, block->page.offset)) { + goto page_corrupted; + } + + decrypted = fil_space_decrypt( + iter.crypt_data, dst, + iter.page_size, src, &err); + + if (err != DB_SUCCESS) { + goto func_exit; + } + + if (!decrypted) { + goto not_encrypted; + } + + updated = true; + } + + /* If the original page is page_compressed, we need + to decompress it before adjusting further. */ + if (page_compressed) { + ulint compress_length = fil_page_decompress( + page_compress_buf, dst); + ut_ad(compress_length != srv_page_size); + if (compress_length == 0) { + goto page_corrupted; + } + updated = true; + } else if (buf_page_is_corrupted( + false, + encrypted && !frame_changed + ? dst : src, + callback.get_zip_size(), NULL)) { + goto page_corrupted; + } + + if ((err = callback(block)) != DB_SUCCESS) { + goto func_exit; + } else if (!updated) { + updated = buf_block_get_state(block) + == BUF_BLOCK_FILE_PAGE; + } + + /* If tablespace is encrypted we use additional + temporary scratch area where pages are read + for decrypting readptr == crypt_io_buffer != io_buffer. + + Destination for decryption is a buffer pool block + block->frame == dst == io_buffer that is updated. + Pages that did not require decryption even when + tablespace is marked as encrypted are not copied + instead block->frame is set to src == readptr. + + For encryption we again use temporary scratch area + writeptr != io_buffer == dst + that is then written to the tablespace + + (1) For normal tables io_buffer == dst == writeptr + (2) For only page compressed tables + io_buffer == dst == writeptr + (3) For encrypted (and page compressed) + readptr != io_buffer == dst != writeptr + */ + + ut_ad(!encrypted && !page_compressed ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(page_compressed && !encrypted ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(encrypted ? + src != dst && dst != writeptr + (i * size):1); + + /* When tablespace is encrypted or compressed its + first page (i.e. page 0) is not encrypted or + compressed and there is no need to copy frame. */ + if (encrypted && block->page.offset != 0) { + byte *local_frame = callback.get_frame(block); + ut_ad((writeptr + (i * size)) != local_frame); + memcpy((writeptr + (i * size)), local_frame, size); + } + + if (frame_changed) { + block->frame = dst; + } + + src = io_buffer + (i * size); + + if (page_compressed) { + updated = true; + if (fil_page_compress( + src, + page_compress_buf, + 0,/* FIXME: compression level */ + 512,/* FIXME: proper block size */ + encrypted)) { + /* FIXME: remove memcpy() */ + memcpy(src, page_compress_buf, + srv_page_size); + } + } + + /* If tablespace is encrypted, encrypt page before we + write it back. Note that we should not encrypt the + buffer that is in buffer pool. */ + /* NOTE: At this stage of IMPORT the + buffer pool is not being used at all! */ + if (decrypted && encrypted) { + byte *dest = writeptr + (i * size); + + byte* tmp = fil_encrypt_buf( + iter.crypt_data, + callback.get_space_id(), + block->page.offset, + mach_read_from_8(src + FIL_PAGE_LSN), + src, + callback.get_zip_size(), + dest); + + if (tmp == src) { + /* TODO: remove unnecessary memcpy's */ + ut_ad(dest != src); + memcpy(dest, src, size); + } + + updated = true; + } + } + + /* A page was updated in the set, write back to disk. */ + if (updated + && !os_file_write( + iter.filepath, iter.file, writeptr, + offset, (ulint) n_bytes)) { + + ib_logf(IB_LOG_LEVEL_ERROR, "os_file_write() failed"); + err = DB_IO_ERROR; + goto func_exit; + } + } + +func_exit: + ut_free(page_compress_buf); + return err; +} + +/********************************************************************//** +Iterate over all the pages in the tablespace. +@param table - the table definiton in the server +@param n_io_buffers - number of blocks to read and write together +@param callback - functor that will do the page updates +@return DB_SUCCESS or error code */ +static +dberr_t +fil_tablespace_iterate( +/*===================*/ + dict_table_t* table, + ulint n_io_buffers, + AbstractCallback& callback) +{ + dberr_t err; + pfs_os_file_t file; + char* filepath; + + ut_a(n_io_buffers > 0); + ut_ad(!srv_read_only_mode); + + DBUG_EXECUTE_IF("ib_import_trigger_corruption_1", + return(DB_CORRUPTION);); + + if (DICT_TF_HAS_DATA_DIR(table->flags)) { + dict_get_and_save_data_dir_path(table, false); + ut_a(table->data_dir_path); + + filepath = os_file_make_remote_pathname( + table->data_dir_path, table->name, "ibd"); + } else { + filepath = fil_make_ibd_name(table->name, false); + } + + { + ibool success; + + file = os_file_create_simple_no_error_handling( + innodb_file_data_key, filepath, + OS_FILE_OPEN, OS_FILE_READ_WRITE, &success, FALSE); + + DBUG_EXECUTE_IF("fil_tablespace_iterate_failure", + { + static bool once; + + if (!once || ut_rnd_interval(0, 10) == 5) { + once = true; + success = FALSE; + os_file_close(file); + } + }); + + if (!success) { + /* The following call prints an error message */ + os_file_get_last_error(true); + + ib_logf(IB_LOG_LEVEL_ERROR, + "Trying to import a tablespace, but could not " + "open the tablespace file %s", filepath); + + mem_free(filepath); + + return(DB_TABLESPACE_NOT_FOUND); + + } else { + err = DB_SUCCESS; + } + } + + callback.set_file(filepath, file); + + os_offset_t file_size = os_file_get_size(file); + ut_a(file_size != (os_offset_t) -1); + + /* Allocate a page to read in the tablespace header, so that we + can determine the page size and zip_size (if it is compressed). + We allocate an extra page in case it is a compressed table. One + page is to ensure alignement. */ + + void* page_ptr = mem_alloc(3 * UNIV_PAGE_SIZE); + byte* page = static_cast(ut_align(page_ptr, UNIV_PAGE_SIZE)); + + /* The block we will use for every physical page */ + buf_block_t block; + + memset(&block, 0, sizeof block); + block.frame = page; + block.page.space = callback.get_space_id(); + block.page.io_fix = BUF_IO_NONE; + block.page.buf_fix_count = 1; + block.page.state = BUF_BLOCK_FILE_PAGE; + + /* Read the first page and determine the page and zip size. */ + + if (!os_file_read_no_error_handling(file, page, 0, UNIV_PAGE_SIZE)) { + + err = DB_IO_ERROR; + + } else if ((err = callback.init(file_size, &block)) == DB_SUCCESS) { + if (const ulint zip_size = callback.get_zip_size()) { + page_zip_set_size(&block.page.zip, zip_size); + /* ROW_FORMAT=COMPRESSED is not optimised for block IO + for now. We do the IMPORT page by page. */ + n_io_buffers = 1; + } + + fil_iterator_t iter; + + iter.file = file; + iter.start = 0; + iter.end = file_size; + iter.filepath = filepath; + iter.file_size = file_size; + iter.n_io_buffers = n_io_buffers; + iter.page_size = callback.get_page_size(); + + /* In MariaDB/MySQL 5.6 tablespace does not exist + during import, therefore we can't use space directly + here. */ + ulint crypt_data_offset = fsp_header_get_crypt_offset( + callback.get_zip_size()); + + /* read (optional) crypt data */ + iter.crypt_data = fil_space_read_crypt_data( + 0, page, crypt_data_offset); + + /** If tablespace is encrypted, it needs extra buffers */ + if (iter.crypt_data != NULL) { + /* decrease io buffers so that memory + * consumption doesnt double + * note: the +1 is to avoid n_io_buffers getting down to 0 */ + iter.n_io_buffers = (iter.n_io_buffers + 1) / 2; + } + + /** Add an extra page for compressed page scratch area. */ + + void* io_buffer = mem_alloc( + (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); + + iter.io_buffer = static_cast( + ut_align(io_buffer, UNIV_PAGE_SIZE)); + + void* crypt_io_buffer = NULL; + if (iter.crypt_data != NULL) { + crypt_io_buffer = mem_alloc( + (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); + iter.crypt_io_buffer = static_cast( + ut_align(crypt_io_buffer, UNIV_PAGE_SIZE)); + } + + if (block.page.zip.ssize) { + ut_ad(iter.n_io_buffers == 1); + block.frame = iter.io_buffer; + block.page.zip.data = block.frame + UNIV_PAGE_SIZE; + ut_d(block.page.zip.m_external = true); + } + + err = fil_iterate(iter, &block, callback); + + mem_free(io_buffer); + + if (crypt_io_buffer != NULL) { + mem_free(crypt_io_buffer); + iter.crypt_io_buffer = NULL; + fil_space_destroy_crypt_data(&iter.crypt_data); + } + } + + if (err == DB_SUCCESS) { + + ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk"); + + if (!os_file_flush(file)) { + ib_logf(IB_LOG_LEVEL_INFO, "os_file_flush() failed!"); + err = DB_IO_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk - done!"); + } + } + + os_file_close(file); + + mem_free(page_ptr); + mem_free(filepath); + + return(err); +} + /*****************************************************************//** Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary. @@ -3597,6 +4000,17 @@ row_import_for_mysql( return(row_import_cleanup(prebuilt, trx, err)); } + /* On DISCARD TABLESPACE, we did not drop any adaptive hash + index entries. If we replaced the discarded tablespace with a + smaller one here, there could still be some adaptive hash + index entries that point to cached garbage pages in the buffer + pool, because PageConverter::operator() only evicted those + pages that were replaced by the imported pages. We must + discard all remaining adaptive hash index entries, because the + adaptive hash index must be a subset of the table contents; + false positives are not tolerated. */ + buf_LRU_drop_page_hash_for_tablespace(table); + row_mysql_lock_data_dictionary(trx); /* If the table is stored in a remote tablespace, we need to diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index fd5a13bbaabd910de0edd7ccd1973cf1ddc460f3..c170e7e8cd339d605e71e4b802acd01bf677d431 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -466,6 +466,8 @@ row_log_table_open( *avail = srv_sort_buf_size - log->tail.bytes; if (size > *avail) { + /* Make sure log->tail.buf is large enough */ + ut_ad(size <= sizeof log->tail.buf); return(log->tail.buf); } else { return(log->tail.block + log->tail.bytes); @@ -584,12 +586,10 @@ row_log_table_delete( { ulint old_pk_extra_size; ulint old_pk_size; - ulint ext_size = 0; ulint mrec_size; ulint avail_size; mem_heap_t* heap = NULL; const dtuple_t* old_pk; - row_ext_t* ext; ut_ad(dict_index_is_clust(index)); ut_ad(rec_offs_validate(rec, index, offsets)); @@ -670,72 +670,20 @@ row_log_table_delete( &old_pk_extra_size); ut_ad(old_pk_extra_size < 0x100); - mrec_size = 6 + old_pk_size; - - /* Log enough prefix of the BLOB unless both the - old and new table are in COMPACT or REDUNDANT format, - which store the prefix in the clustered index record. */ - if (rec_offs_any_extern(offsets) - && (dict_table_get_format(index->table) >= UNIV_FORMAT_B - || dict_table_get_format(new_table) >= UNIV_FORMAT_B)) { - - /* Build a cache of those off-page column prefixes - that are referenced by secondary indexes. It can be - that none of the off-page columns are needed. */ - row_build(ROW_COPY_DATA, index, rec, - offsets, NULL, NULL, NULL, &ext, heap); - if (ext) { - /* Log the row_ext_t, ext->ext and ext->buf */ - ext_size = ext->n_ext * ext->max_len - + sizeof(*ext) - + ext->n_ext * sizeof(ulint) - + (ext->n_ext - 1) * sizeof ext->len; - mrec_size += ext_size; - } - } + /* 2 = 1 (extra_size) + at least 1 byte payload */ + mrec_size = 2 + old_pk_size; if (byte* b = row_log_table_open(index->online_log, mrec_size, &avail_size)) { *b++ = ROW_T_DELETE; *b++ = static_cast(old_pk_extra_size); - /* Log the size of external prefix we saved */ - mach_write_to_4(b, ext_size); - b += 4; - rec_convert_dtuple_to_temp( b + old_pk_extra_size, new_index, old_pk->fields, old_pk->n_fields); b += old_pk_size; - if (ext_size) { - ulint cur_ext_size = sizeof(*ext) - + (ext->n_ext - 1) * sizeof ext->len; - - memcpy(b, ext, cur_ext_size); - b += cur_ext_size; - - /* Check if we need to col_map to adjust the column - number. If columns were added/removed/reordered, - adjust the column number. */ - if (const ulint* col_map = - index->online_log->col_map) { - for (ulint i = 0; i < ext->n_ext; i++) { - const_cast(ext->ext[i]) = - col_map[ext->ext[i]]; - } - } - - memcpy(b, ext->ext, ext->n_ext * sizeof(*ext->ext)); - b += ext->n_ext * sizeof(*ext->ext); - - ext_size -= cur_ext_size - + ext->n_ext * sizeof(*ext->ext); - memcpy(b, ext->buf, ext_size); - b += ext_size; - } - row_log_table_close(index, b, mrec_size, avail_size); } @@ -1654,15 +1602,13 @@ row_log_table_apply_insert( /******************************************************//** Deletes a record from a table that is being rebuilt. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull(1, 2, 4, 5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_delete_low( /*===========================*/ btr_pcur_t* pcur, /*!< in/out: B-tree cursor, will be trashed */ const ulint* offsets, /*!< in: offsets on pcur */ - const row_ext_t* save_ext, /*!< in: saved external field - info, or NULL */ mem_heap_t* heap, /*!< in/out: memory heap */ mtr_t* mtr) /*!< in/out: mini-transaction, will be committed */ @@ -1686,11 +1632,7 @@ row_log_table_apply_delete_low( /* Build a row template for purging secondary index entries. */ row = row_build( ROW_COPY_DATA, index, btr_pcur_get_rec(pcur), - offsets, NULL, NULL, NULL, - save_ext ? NULL : &ext, heap); - if (!save_ext) { - save_ext = ext; - } + offsets, NULL, NULL, NULL, &ext, heap); } else { row = NULL; } @@ -1709,7 +1651,7 @@ row_log_table_apply_delete_low( } const dtuple_t* entry = row_build_index_entry( - row, save_ext, index, heap); + row, ext, index, heap); mtr_start(mtr); btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, pcur, mtr); @@ -1752,11 +1694,10 @@ row_log_table_apply_delete_low( /******************************************************//** Replays a delete operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_delete( /*=======================*/ - que_thr_t* thr, /*!< in: query graph */ ulint trx_id_col, /*!< in: position of DB_TRX_ID in the new clustered index */ @@ -1765,9 +1706,7 @@ row_log_table_apply_delete( mem_heap_t* offsets_heap, /*!< in/out: memory heap that can be emptied */ mem_heap_t* heap, /*!< in/out: memory heap */ - const row_log_t* log, /*!< in: online log */ - const row_ext_t* save_ext) /*!< in: saved external field - info, or NULL */ + const row_log_t* log) /*!< in: online log */ { dict_table_t* new_table = log->table; dict_index_t* index = dict_table_get_first_index(new_table); @@ -1867,8 +1806,7 @@ row_log_table_apply_delete( } } - return(row_log_table_apply_delete_low(&pcur, offsets, save_ext, - heap, &mtr)); + return row_log_table_apply_delete_low(&pcur, offsets, heap, &mtr); } /******************************************************//** @@ -2079,7 +2017,7 @@ row_log_table_apply_update( /* Some BLOBs are missing, so we are interpreting this ROW_T_UPDATE as ROW_T_DELETE (see *1). */ error = row_log_table_apply_delete_low( - &pcur, cur_offsets, NULL, heap, &mtr); + &pcur, cur_offsets, heap, &mtr); goto func_exit_committed; } @@ -2117,7 +2055,7 @@ row_log_table_apply_update( } error = row_log_table_apply_delete_low( - &pcur, cur_offsets, NULL, heap, &mtr); + &pcur, cur_offsets, heap, &mtr); ut_ad(mtr.state == MTR_COMMITTED); if (error == DB_SUCCESS) { @@ -2263,8 +2201,6 @@ row_log_table_apply_op( ulint extra_size; const mrec_t* next_mrec; dtuple_t* old_pk; - row_ext_t* ext; - ulint ext_size; ut_ad(dict_index_is_clust(dup->index)); ut_ad(dup->index->table != log->table); @@ -2272,7 +2208,7 @@ row_log_table_apply_op( *error = DB_SUCCESS; - /* 3 = 1 (op type) + 1 (ext_size) + at least 1 byte payload */ + /* 3 = 1 (op type) + 1 (extra_size) + at least 1 byte payload */ if (mrec + 3 >= mrec_end) { return(NULL); } @@ -2322,14 +2258,12 @@ row_log_table_apply_op( break; case ROW_T_DELETE: - /* 1 (extra_size) + 4 (ext_size) + at least 1 (payload) */ - if (mrec + 6 >= mrec_end) { + /* 1 (extra_size) + at least 1 (payload) */ + if (mrec + 2 >= mrec_end) { return(NULL); } extra_size = *mrec++; - ext_size = mach_read_from_4(mrec); - mrec += 4; ut_ad(mrec < mrec_end); /* We assume extra_size < 0x100 for the PRIMARY KEY prefix. @@ -2338,40 +2272,16 @@ row_log_table_apply_op( rec_offs_set_n_fields(offsets, new_index->n_uniq + 2); rec_init_offsets_temp(mrec, new_index, offsets); - next_mrec = mrec + rec_offs_data_size(offsets) + ext_size; + next_mrec = mrec + rec_offs_data_size(offsets); if (next_mrec > mrec_end) { return(NULL); } log->head.total += next_mrec - mrec_start; - /* If there are external fields, retrieve those logged - prefix info and reconstruct the row_ext_t */ - if (ext_size) { - /* We use memcpy to avoid unaligned - access on some non-x86 platforms.*/ - ext = static_cast( - mem_heap_dup(heap, - mrec + rec_offs_data_size(offsets), - ext_size)); - - byte* ext_start = reinterpret_cast(ext); - - ulint ext_len = sizeof(*ext) - + (ext->n_ext - 1) * sizeof ext->len; - - ext->ext = reinterpret_cast(ext_start + ext_len); - ext_len += ext->n_ext * sizeof(*ext->ext); - - ext->buf = static_cast(ext_start + ext_len); - } else { - ext = NULL; - } - *error = row_log_table_apply_delete( - thr, new_trx_id_col, - mrec, offsets, offsets_heap, heap, - log, ext); + new_trx_id_col, + mrec, offsets, offsets_heap, heap, log); break; case ROW_T_UPDATE: @@ -2796,7 +2706,15 @@ row_log_table_apply_ops( while (!trx_is_interrupted(trx)) { mrec = next_mrec; - ut_ad(mrec < mrec_end); + ut_ad(mrec <= mrec_end); + + if (mrec == mrec_end) { + /* We are at the end of the log. + Mark the replay all_done. */ + if (has_index_lock) { + goto all_done; + } + } if (!has_index_lock) { /* We are applying operations from a different diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 80ab10cdbc0d1052eb9bc020f980a40996cfeb12..0206d4153425ae90aec52e862735c92619146523 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3108,7 +3108,8 @@ row_merge_drop_indexes( A concurrent purge will be prevented by dict_operation_lock. */ - if (!locked && table->n_ref_count > 1) { + if (!locked && (table->n_ref_count > 1 + || UT_LIST_GET_FIRST(table->locks))) { /* We will have to drop the indexes later, when the table is guaranteed to be no longer in use. Mark the indexes as incomplete and corrupted, so that other diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 36ca5c7767b0f6579ff3c37ff60083b9f9e06695..be24ae885a25dc63d09ea8e01ede51929d6c7514 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1499,8 +1499,7 @@ row_insert_for_mysql( doc_ids difference should not exceed FTS_DOC_ID_MAX_STEP value. */ - if (next_doc_id > 1 - && doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { + if (doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { fprintf(stderr, "InnoDB: Doc ID " UINT64PF " is too" " big. Its difference with largest" @@ -3517,6 +3516,8 @@ row_truncate_table_for_mysql( fil_space_release(space); } + buf_LRU_drop_page_hash_for_tablespace(table); + if (flags != ULINT_UNDEFINED && fil_discard_tablespace(space_id) == DB_SUCCESS) { @@ -4210,6 +4211,21 @@ row_drop_table_for_mysql( rw_lock_x_unlock(dict_index_get_lock(index)); } + if (table->space != TRX_SYS_SPACE) { + /* On DISCARD TABLESPACE, we would not drop the + adaptive hash index entries. If the tablespace is + missing here, delete-marking the record in SYS_INDEXES + would not free any pages in the buffer pool. Thus, + dict_index_remove_from_cache() would hang due to + adaptive hash index entries existing in the buffer + pool. To prevent this hang, and also to guarantee + that btr_search_drop_page_hash_when_freed() will avoid + calling btr_search_drop_page_hash_index() while we + hold the InnoDB dictionary lock, we will drop any + adaptive hash index entries upfront. */ + buf_LRU_drop_page_hash_for_tablespace(table); + } + /* We use the private SQL parser of Innobase to generate the query graphs needed in deleting the dictionary data from system tables in Innobase. Deleting a row from SYS_INDEXES table also @@ -5239,7 +5255,8 @@ row_rename_table_for_mysql( } } - if (dict_table_has_fts_index(table) + if ((dict_table_has_fts_index(table) + || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) && !dict_tables_have_same_db(old_name, new_name)) { err = fts_rename_aux_tables(table, new_name, trx); if (err != DB_TABLE_NOT_FOUND) { @@ -5341,6 +5358,7 @@ row_rename_table_for_mysql( trx_rollback_to_savepoint(trx, NULL); trx->error_state = DB_SUCCESS; } + table->data_dir_path= NULL; } funct_exit: diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 6cca3e21c794870add0d4c050c57c5776009623b..06bf4cc30c0c41fc04341dd1ba7d8c4c1242ac92 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -2707,7 +2707,9 @@ row_sel_field_store_in_mysql_format_func( || !(templ->mysql_col_len % templ->mbmaxlen)); ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len || (field_no == templ->icp_rec_field_no - && field->prefix_len > 0)); + && field->prefix_len > 0) + || templ->rec_field_is_prefix); + ut_ad(!(field->prefix_len % templ->mbmaxlen)); if (templ->mbminlen == 1 && templ->mbmaxlen != 1) { @@ -3667,6 +3669,118 @@ row_search_idx_cond_check( return(result); } +/** Return the record field length in characters. +@param[in] col table column of the field +@param[in] field_no field number +@param[in] rec physical record +@param[in] offsets field offsets in the physical record +@return field length in characters. */ +static +size_t +rec_field_len_in_chars( + const dict_col_t* col, + const ulint field_no, + const rec_t* rec, + const ulint* offsets) +{ + const ulint cset = dtype_get_charset_coll(col->prtype); + const CHARSET_INFO* cs = all_charsets[cset]; + ulint rec_field_len; + const char* rec_field = reinterpret_cast( + rec_get_nth_field( + rec, offsets, field_no, &rec_field_len)); + + if (UNIV_UNLIKELY(!cs)) { + ib_logf(IB_LOG_LEVEL_WARN, "Missing collation " ULINTPF, cset); + return SIZE_T_MAX; + } + + return(cs->cset->numchars(cs, rec_field, rec_field + rec_field_len)); +} + +/** Avoid the clustered index lookup if all the following conditions +are true: +1) all columns are in secondary index +2) all values for columns that are prefix-only indexes are shorter +than the prefix size. This optimization can avoid many IOs for certain schemas. +@return true, to avoid clustered index lookup. */ +static +bool row_search_with_covering_prefix( + row_prebuilt_t* prebuilt, + const rec_t* rec, + const ulint* offsets) +{ + const dict_index_t* index = prebuilt->index; + ut_ad(!dict_index_is_clust(index)); + + if (!srv_prefix_index_cluster_optimization) { + return false; + } + + /** Optimization only applicable if there the number of secondary index + fields are greater than or equal to number of clustered index fields. */ + if (prebuilt->n_template > index->n_fields) { + return false; + } + + for (ulint i = 0; i < prebuilt->n_template; i++) { + mysql_row_templ_t* templ = prebuilt->mysql_template + i; + ulint j = templ->rec_prefix_field_no; + + /** Condition (1) : is the field in the index. */ + if (j == ULINT_UNDEFINED) { + return false; + } + + /** Condition (2): If this is a prefix index then + row's value size shorter than prefix length. */ + + if (!templ->rec_field_is_prefix) { + continue; + } + + ulint rec_size = rec_offs_nth_size(offsets, j); + const dict_field_t* field = dict_index_get_nth_field(index, j); + ulint max_chars = field->prefix_len / templ->mbmaxlen; + + ut_a(field->prefix_len > 0); + + if (rec_size < max_chars) { + /* Record in bytes shorter than the index + prefix length in char. */ + continue; + } + + if (rec_size * templ->mbminlen >= field->prefix_len) { + /* Shortest representation string by the + byte length of the record is longer than the + maximum possible index prefix. */ + return false; + } + + size_t num_chars = rec_field_len_in_chars( + field->col, j, rec, offsets); + + if (num_chars >= max_chars) { + /* No of chars to store the record exceeds + the index prefix character length. */ + return false; + } + } + + /* If prefix index optimization condition satisfied then + for all columns above, use rec_prefix_field_no instead of + rec_field_no, and skip the clustered lookup below. */ + for (ulint i = 0; i < prebuilt->n_template; i++) { + mysql_row_templ_t* templ = prebuilt->mysql_template + i; + templ->rec_field_no = templ->rec_prefix_field_no; + ut_a(templ->rec_field_no != ULINT_UNDEFINED); + } + + srv_stats.n_sec_rec_cluster_reads_avoided.inc(); + return true; +} + /********************************************************************//** Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next @@ -3729,7 +3843,6 @@ row_search_for_mysql( ulint* offsets = offsets_; ibool table_lock_waited = FALSE; byte* next_buf = 0; - ibool use_clustered_index = FALSE; rec_offs_init(offsets_); @@ -4543,9 +4656,27 @@ row_search_for_mysql( ulint lock_type; + if (srv_locks_unsafe_for_binlog + || trx->isolation_level <= TRX_ISO_READ_COMMITTED) { + /* At READ COMMITTED or READ UNCOMMITTED + isolation levels, do not lock committed + delete-marked records. */ + if (!rec_get_deleted_flag(rec, comp)) { + goto no_gap_lock; + } + if (trx_id_t trx_id = index == clust_index + ? row_get_rec_trx_id(rec, index, offsets) + : row_vers_impl_x_locked(rec, index, offsets)) { + if (trx_rw_is_active(trx_id, NULL)) { + /* The record belongs to an active + transaction. We must acquire a lock. */ + goto no_gap_lock; + } + } + goto locks_ok_del_marked; + } + if (!set_also_gap_locks - || srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED || (unique_search && !rec_get_deleted_flag(rec, comp))) { goto no_gap_lock; @@ -4615,7 +4746,11 @@ row_search_for_mysql( a deadlock and the transaction had to wait then release the lock it is waiting on. */ + lock_mutex_enter(); + trx_mutex_enter(trx); err = lock_trx_handle_wait(trx); + lock_mutex_exit(); + trx_mutex_exit(trx); switch (err) { case DB_SUCCESS: @@ -4732,20 +4867,9 @@ row_search_for_mysql( page_rec_is_comp() cannot be used! */ if (rec_get_deleted_flag(rec, comp)) { - +locks_ok_del_marked: /* The record is delete-marked: we can skip it */ - if ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE - && !did_semi_consistent_read) { - - /* No need to keep a lock on a delete-marked record - if we do not want to use next-key locking. */ - - row_unlock_for_mysql(prebuilt, TRUE); - } - /* This is an optimization to skip setting the next key lock on the record that follows this delete-marked record. This optimization works because of the unique search criteria @@ -4786,69 +4910,10 @@ row_search_for_mysql( break; } - /* Get the clustered index record if needed, if we did not do the - search using the clustered index... */ - - use_clustered_index = - (index != clust_index && prebuilt->need_to_access_clustered); - - if (use_clustered_index && srv_prefix_index_cluster_optimization - && prebuilt->n_template <= index->n_fields) { - /* ...but, perhaps avoid the clustered index lookup if - all of the following are true: - 1) all columns are in the secondary index - 2) all values for columns that are prefix-only - indexes are shorter than the prefix size - This optimization can avoid many IOs for certain schemas. - */ - ibool row_contains_all_values = TRUE; - int i; - for (i = 0; i < prebuilt->n_template; i++) { - /* Condition (1) from above: is the field in the - index (prefix or not)? */ - mysql_row_templ_t* templ = - prebuilt->mysql_template + i; - ulint secondary_index_field_no = - templ->rec_prefix_field_no; - if (secondary_index_field_no == ULINT_UNDEFINED) { - row_contains_all_values = FALSE; - break; - } - /* Condition (2) from above: if this is a - prefix, is this row's value size shorter - than the prefix? */ - if (templ->rec_field_is_prefix) { - ulint record_size = rec_offs_nth_size( - offsets, - secondary_index_field_no); - const dict_field_t *field = - dict_index_get_nth_field( - index, - secondary_index_field_no); - ut_a(field->prefix_len > 0); - if (record_size >= field->prefix_len) { - row_contains_all_values = FALSE; - break; - } - } + if (index != clust_index && prebuilt->need_to_access_clustered) { + if (row_search_with_covering_prefix(prebuilt, rec, offsets)) { + goto use_covering_index; } - /* If (1) and (2) were true for all columns above, use - rec_prefix_field_no instead of rec_field_no, and skip - the clustered lookup below. */ - if (row_contains_all_values) { - for (i = 0; i < prebuilt->n_template; i++) { - mysql_row_templ_t* templ = - prebuilt->mysql_template + i; - templ->rec_field_no = - templ->rec_prefix_field_no; - ut_a(templ->rec_field_no != ULINT_UNDEFINED); - } - use_clustered_index = FALSE; - srv_stats.n_sec_rec_cluster_reads_avoided.inc(); - } - } - - if (use_clustered_index) { requires_clust_rec: ut_ad(index != clust_index); /* We use a 'goto' to the preceding label if a consistent @@ -4934,6 +4999,7 @@ row_search_for_mysql( } } } else { +use_covering_index: result_rec = rec; } diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index e2de47bf86aab3c1c37ff1ad27a8a11cb2d9adf8..33f46882651447e192c81ab04506f4040d875628 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1803,6 +1803,23 @@ row_upd_store_row( } } +#ifdef WITH_WSREP +/** Determine if a FOREIGN KEY constraint needs to be processed. +@param[in] node query node +@param[in] trx transaction +@return whether the node cannot be ignored */ + +inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) +{ + if (!wsrep_on_trx(trx)) { + return false; + } + return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE + || static_cast(node->common.parent)->cascade_node + != node; +} +#endif /* WITH_WSREP */ + /***********************************************************//** Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error @@ -1833,7 +1850,7 @@ row_upd_sec_index_entry( referenced = row_upd_index_is_referenced(index, trx); #ifdef WITH_WSREP - ibool foreign = wsrep_row_upd_index_is_foreign(index, trx); + bool foreign = wsrep_row_upd_index_is_foreign(index, trx); #endif /* WITH_WSREP */ heap = mem_heap_create(1024); @@ -1962,61 +1979,61 @@ row_upd_sec_index_entry( row_ins_sec_index_entry() below */ if (!rec_get_deleted_flag( rec, dict_table_is_comp(index->table))) { -#ifdef WITH_WSREP - que_node_t *parent = que_node_get_parent(node); -#endif /* WITH_WSREP */ err = btr_cur_del_mark_set_sec_rec( 0, btr_cur, TRUE, thr, &mtr); - if (err == DB_SUCCESS && referenced) { - - ulint* offsets; - - offsets = rec_get_offsets( - rec, index, NULL, ULINT_UNDEFINED, - &heap); - - /* NOTE that the following call loses - the position of pcur ! */ - err = row_upd_check_references_constraints( - node, &pcur, index->table, - index, offsets, thr, &mtr); + if (err != DB_SUCCESS) { + break; } + #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && - wsrep_on_trx(trx) && - !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - !(parent && que_node_get_type(parent) == - QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { - ulint* offsets = - rec_get_offsets( + if (!referenced && foreign + && wsrep_must_process_fk(node, trx) + && !wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + ulint* offsets = rec_get_offsets( rec, index, NULL, ULINT_UNDEFINED, &heap); + err = wsrep_row_upd_check_foreign_constraints( node, &pcur, index->table, index, offsets, thr, &mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: sec index FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } } #endif /* WITH_WSREP */ } - break; + + if (referenced) { + + ulint* offsets; + + offsets = rec_get_offsets( + rec, index, NULL, ULINT_UNDEFINED, + &heap); + + /* NOTE that the following call loses + the position of pcur ! */ + err = row_upd_check_references_constraints( + node, &pcur, index->table, + index, offsets, thr, &mtr); + } } btr_pcur_close(&pcur); @@ -2185,9 +2202,6 @@ row_upd_clust_rec_by_insert( rec_t* rec; ulint* offsets = NULL; -#ifdef WITH_WSREP - que_node_t *parent = que_node_get_parent(node); -#endif /* WITH_WSREP */ ut_ad(node); ut_ad(dict_index_is_clust(index)); @@ -2269,35 +2283,31 @@ row_upd_clust_rec_by_insert( if (err != DB_SUCCESS) { goto err_exit; } - } #ifdef WITH_WSREP - if (!referenced && wsrep_on_trx(trx) && - !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { + } else if ((foreign && wsrep_must_process_fk(node, trx))) { err = wsrep_row_upd_check_foreign_constraints( node, pcur, table, index, offsets, thr, mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: insert FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } - if (err != DB_SUCCESS) { - goto err_exit; - } - } #endif /* WITH_WSREP */ + } } mtr_commit(mtr); @@ -2500,7 +2510,7 @@ row_upd_del_mark_clust_rec( dberr_t err; #ifdef WITH_WSREP rec_t* rec; - que_node_t *parent = que_node_get_parent(node); + trx_t* trx = thr_get_trx(thr) ; #endif /* WITH_WSREP */ ut_ad(node); @@ -2529,38 +2539,37 @@ row_upd_del_mark_clust_rec( btr_cur_get_block(btr_cur), btr_cur_get_rec(btr_cur), #endif /* WITH_WSREP */ index, offsets, thr, mtr); - if (err == DB_SUCCESS && referenced) { + if (err != DB_SUCCESS) { + } else if (referenced) { /* NOTE that the following call loses the position of pcur ! */ err = row_upd_check_references_constraints( node, pcur, index->table, index, offsets, thr, mtr); - } #ifdef WITH_WSREP - trx_t* trx = thr_get_trx(thr) ; - if (err == DB_SUCCESS && !referenced && wsrep_on_trx(trx) && - !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { + } else if (foreign && wsrep_must_process_fk(node, trx)) { err = wsrep_row_upd_check_foreign_constraints( node, pcur, index->table, index, offsets, thr, mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: clust rec FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: clust rec referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } - } #endif /* WITH_WSREP */ + } mtr_commit(mtr); diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index cb003edfbdc6d3d13b2ce567c9ea5930d009a954..6e8ed7893d624ce7e302a638ce831f6245a1e210 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -77,6 +77,12 @@ Created 10/8/1995 Heikki Tuuri #include "fil0pagecompress.h" #include "btr0scrub.h" +#include + +#ifdef WITH_WSREP +extern int wsrep_debug; +extern int wsrep_trx_is_aborting(void *thd_ptr); +#endif /* The following is the maximum allowed duration of a lock wait. */ UNIV_INTERN ulong srv_fatal_semaphore_wait_threshold = DEFAULT_SRV_FATAL_SEMAPHORE_TIMEOUT; @@ -421,16 +427,6 @@ static ulint srv_n_system_rows_read_old = 0; UNIV_INTERN ulint srv_truncated_status_writes = 0; UNIV_INTERN ulint srv_available_undo_logs = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_saved = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect512 = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect4096 = 0; -UNIV_INTERN ib_uint64_t srv_index_pages_written = 0; -UNIV_INTERN ib_uint64_t srv_non_index_pages_written = 0; -UNIV_INTERN ib_uint64_t srv_pages_page_compressed = 0; -UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op = 0; -UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op_saved = 0; -UNIV_INTERN ib_uint64_t srv_index_page_decompressed = 0; - /* Defragmentation */ UNIV_INTERN my_bool srv_defragment = FALSE; UNIV_INTERN uint srv_defragment_n_pages = 7; @@ -2546,6 +2542,9 @@ srv_purge_should_exit(ulint n_purged) } /* Slow shutdown was requested. */ if (n_purged) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "InnoDB " ULINTPF " pages purged", n_purged); /* The previous round still did some work. */ return(false); } @@ -2736,7 +2735,6 @@ srv_do_purge( (++count % TRX_SYS_N_RSEGS) == 0); *n_total_purged += n_pages_purged; - } while (!srv_purge_should_exit(n_pages_purged) && n_pages_purged > 0 && purge_sys->state == PURGE_STATE_RUN); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index e5c57aa21cec226f96446adc2e26cac800d4de0f..3fd71aff23ad9ed5a7bca0a0d16acc981aca0a01 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -25,7 +25,7 @@ Created 3/26/1996 Heikki Tuuri *******************************************************/ #include "my_config.h" -#include +#include #include "trx0roll.h" @@ -752,11 +752,17 @@ trx_roll_must_shutdown() n_rows += t->undo_no; } } + + if (n_rows > 0) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "To roll back: " ULINTPF " transactions, " + "%llu rows", n_trx, n_rows); + } + ib_logf(IB_LOG_LEVEL_INFO, "To roll back: " ULINTPF " transactions, " "%llu rows", n_trx, n_rows); - sd_notifyf(0, "STATUS=To roll back: " ULINTPF " transactions, " - "%llu rows", n_trx, n_rows); } mutex_exit(&recv_sys->mutex); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 1cd0b6ede51237bee3b402e8f8adabe7b989f89c..6d4bb2022913e061a854732e58365266da73e3bf 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2017, MariaDB Corporation. +Copyright (c) 2015, 2018, 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 @@ -1256,6 +1256,8 @@ trx_commit_in_memory( trx->read_view = NULL; if (lsn) { + DEBUG_SYNC_C("after_trx_committed_in_memory"); + if (trx->insert_undo != NULL) { trx_undo_insert_cleanup(trx); diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index d6bcd131a4f17b80f252b4777a536f62aac1ae55..370b3f181a133ab4ad0fc94943da4893dd4a9b83 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -1989,7 +1989,9 @@ trx_undo_insert_cleanup( mutex_exit(&(rseg->mutex)); - trx_undo_seg_free(undo); + if (!srv_read_only_mode) { + trx_undo_seg_free(undo); + } mutex_enter(&(rseg->mutex)); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 47b24e1030b653af00bc49c4e4906409117d9e5e..eee6b502c478057363c866242b77cd20a4920064 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -37,6 +37,7 @@ C_MODE_START #include "ma_checkpoint.h" #include "ma_recovery.h" C_MODE_END +#include "ma_trnman.h" //#include "sql_priv.h" #include "protocol.h" @@ -978,7 +979,7 @@ int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | HA_FILE_BASED | HA_CAN_GEOMETRY | CANNOT_ROLLBACK_FLAG | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS | HA_CAN_REPAIR | - HA_CAN_VIRTUAL_COLUMNS | + HA_CAN_VIRTUAL_COLUMNS | HA_CAN_EXPORT | HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT), can_enable_indexes(1), bulk_insert_single_undo(BULK_INSERT_NONE) {} @@ -1323,6 +1324,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) old_proc_info= thd_proc_info(thd, "Checking status"); thd_progress_init(thd, 3); error= maria_chk_status(param, file); // Not fatal + /* maria_chk_size() will flush the page cache for this file */ if (maria_chk_size(param, file)) error= 1; if (!error) @@ -1381,7 +1383,8 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt) } /* Reset trn, that may have been set by repair */ - _ma_set_trn_for_table(file, old_trn); + if (old_trn && old_trn != file->trn) + _ma_set_trn_for_table(file, old_trn); thd_proc_info(thd, old_proc_info); thd_progress_end(thd); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; @@ -1515,7 +1518,8 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt) error=maria_zerofill(param, file, share->open_file_name.str); /* Reset trn, that may have been set by repair */ - _ma_set_trn_for_table(file, old_trn); + if (old_trn && old_trn != file->trn) + _ma_set_trn_for_table(file, old_trn); if (!error) { @@ -1755,7 +1759,8 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) maria_lock_database(file, F_UNLCK); /* Reset trn, that may have been set by repair */ - _ma_set_trn_for_table(file, old_trn); + if (old_trn && old_trn != file->trn) + _ma_set_trn_for_table(file, old_trn); error= error ? HA_ADMIN_FAILED : (optimize_done ? (write_log_record_for_repair(param, file) ? HA_ADMIN_FAILED : @@ -2222,6 +2227,7 @@ int ha_maria::end_bulk_insert() _ma_reenable_logging_for_table(file, bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR); + bulk_insert_single_undo= BULK_INSERT_NONE; // Safety } DBUG_RETURN(err); } @@ -2565,9 +2571,12 @@ int ha_maria::extra(enum ha_extra_function operation) without calling commit/rollback in between. If file->trn is not set we can't remove file->share from the transaction list in the extra() call. - We also ensure that we set file->trn to 0 if THD_TRN is 0 as in - this case we have already freed the trn. This can happen when one - implicit_commit() is called as part of alter table. + In current code we don't have to do this for HA_EXTRA_PREPARE_FOR_RENAME + as this is only used the intermediate table used by ALTER TABLE which + is not part of the transaction (it's not in the TRN list). Better to + keep this for now, to not break anything in a stable release. + When HA_EXTRA_PREPARE_FOR_RENAME is not handled below, we can change + the warnings in _ma_remove_table_from_trnman() to asserts. table->in_use is not set in the case this is a done as part of closefrm() as part of drop table. @@ -2580,7 +2589,7 @@ int ha_maria::extra(enum ha_extra_function operation) { THD *thd= table->in_use; TRN *trn= THD_TRN; - _ma_set_trn_for_table(file, trn); + _ma_set_tmp_trn_for_table(file, trn); } DBUG_ASSERT(file->s->base.born_transactional || file->trn == 0 || file->trn == &dummy_transaction_object); @@ -2696,6 +2705,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) if (file->trn) { /* This can only happen with tables created with clone() */ + DBUG_PRINT("info",("file->trn: %p", file->trn)); trnman_increment_locked_tables(file->trn); } @@ -2716,7 +2726,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) } else { - TRN *trn= THD_TRN; + TRN *trn= (file->trn != &dummy_transaction_object ? file->trn : 0); /* End of transaction */ /* @@ -2731,8 +2741,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) */ if (_ma_reenable_logging_for_table(file, TRUE)) DBUG_RETURN(1); - /** @todo zero file->trn also in commit and rollback */ - _ma_set_trn_for_table(file, NULL); // Safety + _ma_reset_trn_for_table(file); /* Ensure that file->state points to the current number of rows. This is needed if someone calls maria_info() without first doing an @@ -2788,13 +2797,6 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type) DBUG_ASSERT(lock_type != TL_UNLOCK); DBUG_ASSERT(file->trn == trn); - /* - If there was an implicit commit under this LOCK TABLES by a previous - statement (like a DDL), at least if that previous statement was about a - different ha_maria than 'this' then this->file->trn is a stale - pointer. We fix it: - */ - _ma_set_trn_for_table(file, trn); /* As external_lock() was already called, don't increment locked_tables. Note that we call the function below possibly several times when @@ -2819,6 +2821,23 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type) } +/* + Reset THD_TRN and all file->trn related to the transaction + This is needed as some calls, like extra() or external_lock() may access + it before next transaction is started +*/ + +static void reset_thd_trn(THD *thd, MARIA_HA *first_table) +{ + DBUG_ENTER("reset_thd_trn"); + THD_TRN= NULL; + for (MARIA_HA *table= first_table; table ; + table= table->trn_next) + _ma_reset_trn_for_table(table); + DBUG_VOID_RETURN; +} + + /** Performs an implicit commit of the Maria transaction and creates a new one. @@ -2842,10 +2861,10 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) TRN *trn; int error; uint locked_tables; - DYNAMIC_ARRAY used_tables; extern my_bool plugins_are_initialized; - + MARIA_HA *used_tables, *trn_next; DBUG_ENTER("ha_maria::implicit_commit"); + if (!maria_hton || !plugins_are_initialized || !(trn= THD_TRN)) DBUG_RETURN(0); if (!new_trn && (thd->locked_tables_mode == LTM_LOCK_TABLES || @@ -2863,48 +2882,16 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) locked_tables= trnman_has_locked_tables(trn); - if (new_trn && trn && trn->used_tables) - { - MARIA_USED_TABLES *tables; - /* - Save locked tables so that we can move them to another transaction - We are using a dynamic array as locked_tables in some cases can be - smaller than the used_tables list (for example when the server does - early unlock of tables. - */ - - my_init_dynamic_array2(&used_tables, sizeof(MARIA_SHARE*), (void*) 0, - locked_tables, 8, MYF(MY_THREAD_SPECIFIC)); - for (tables= (MARIA_USED_TABLES*) trn->used_tables; - tables; - tables= tables->next) - { - if (tables->share->base.born_transactional) - { - if (insert_dynamic(&used_tables, (uchar*) &tables->share)) - { - error= HA_ERR_OUT_OF_MEM; - goto end_and_free; - } - } - } - } - else - bzero(&used_tables, sizeof(used_tables)); - + used_tables= (MARIA_HA*) trn->used_instances; error= 0; if (unlikely(ma_commit(trn))) error= 1; if (!new_trn) { - /* - To be extra safe, we should also reset file->trn for all open - tables as some calls, like extra() may access it. We take care - of this in extra() by resetting file->trn if THD_TRN is 0. - */ - THD_TRN= NULL; + reset_thd_trn(thd, used_tables); goto end; } + /* We need to create a new transaction and put it in THD_TRN. Indeed, tables may be under LOCK TABLES, and so they will start the next @@ -2914,8 +2901,9 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) THD_TRN= trn; if (unlikely(trn == NULL)) { + reset_thd_trn(thd, used_tables); error= HA_ERR_OUT_OF_MEM; - goto end_and_free; + goto end; } /* Move all locked tables to the new transaction @@ -2925,35 +2913,25 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) in check table, we use the table without calling start_stmt(). */ - uint i; - for (i= 0 ; i < used_tables.elements ; i++) + for (MARIA_HA *handler= used_tables; handler ; + handler= trn_next) { - MARIA_SHARE *share; - LIST *handlers; + trn_next= handler->trn_next; + DBUG_ASSERT(handler->s->base.born_transactional); - share= *(dynamic_element(&used_tables, i, MARIA_SHARE**)); - /* Find table instances that was used in this transaction */ - for (handlers= share->open_list; handlers; handlers= handlers->next) + /* If handler uses versioning */ + if (handler->s->lock_key_trees) { - MARIA_HA *handler= (MARIA_HA*) handlers->data; - if (handler->external_ref && - ((TABLE*) handler->external_ref)->in_use == thd) - { - _ma_set_trn_for_table(handler, trn); - /* If handler uses versioning */ - if (handler->s->lock_key_trees) - { - if (_ma_setup_live_state(handler)) - error= HA_ERR_OUT_OF_MEM; - } - } + /* _ma_set_trn_for_table() will be called indirectly */ + if (_ma_setup_live_state(handler)) + error= HA_ERR_OUT_OF_MEM; } + else + _ma_set_trn_for_table(handler, trn); } /* This is just a commit, tables stay locked if they were: */ trnman_reset_locked_tables(trn, locked_tables); -end_and_free: - delete_dynamic(&used_tables); end: DBUG_RETURN(error); } @@ -3326,10 +3304,10 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)), trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); /* statement or transaction ? */ - if ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && !all) + if ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && + !all) DBUG_RETURN(0); // end of statement - DBUG_PRINT("info", ("THD_TRN set to 0x0")); - THD_TRN= 0; + reset_thd_trn(thd, (MARIA_HA*) trn->used_instances); DBUG_RETURN(ma_commit(trn)); // end of transaction } @@ -3346,8 +3324,7 @@ static int maria_rollback(handlerton *hton __attribute__ ((unused)), trnman_rollback_statement(trn); DBUG_RETURN(0); // end of statement } - DBUG_PRINT("info", ("THD_TRN set to 0x0")); - THD_TRN= 0; + reset_thd_trn(thd, (MARIA_HA*) trn->used_instances); DBUG_RETURN(trnman_rollback_trn(trn) ? HA_ERR_OUT_OF_MEM : 0); // end of transaction } diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 65fe5f545d1f338cc1c8eb16c58d0d7fe87e3035..f3548a381371ee6e1b6d78d9d7b9ecbfba217d65 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -193,6 +193,7 @@ class ha_maria :public handler private: DsMrr_impl ds_mrr; friend ICP_RESULT index_cond_func_maria(void *arg); + friend void reset_thd_trn(THD *thd); }; #endif /* HA_MARIA_INCLUDED */ diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 9ab5533fdbd090429f142e634dfbffbfe3f352d4..e8e2bc56b25cd6cc695b3298d98682d7fed53609 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -145,6 +145,11 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, pgcache_page_no_t page); static void _ma_bitmap_unpin_all(MARIA_SHARE *share); +#ifndef DBUG_OFF +static void _ma_check_bitmap(MARIA_FILE_BITMAP *bitmap); +#else +#define _ma_check_bitmap(A) do { } while(0) +#endif /* Write bitmap page to key cache */ @@ -267,6 +272,13 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file, bitmap->sizes[6]= max_page_size - max_page_size * 80 / 100; bitmap->sizes[7]= 0; + /* + If a record size will fit into the smallest empty page, return first + found page in find_head() + */ + if (bitmap->sizes[3] >= share->base.max_pack_length) + bitmap->return_first_match= 1; + mysql_mutex_init(key_SHARE_BITMAP_lock, &share->bitmap.bitmap_lock, MY_MUTEX_INIT_SLOW); mysql_cond_init(key_SHARE_BITMAP_cond, @@ -677,7 +689,8 @@ void _ma_bitmap_delete_all(MARIA_SHARE *share) bzero(bitmap->map, bitmap->block_size); bitmap->changed= 1; bitmap->page= 0; - bitmap->used_size= bitmap->total_size= bitmap->max_total_size; + bitmap->used_size= bitmap->full_tail_size= bitmap->full_head_size= 0; + bitmap->total_size= bitmap->max_total_size; } DBUG_VOID_RETURN; } @@ -715,6 +728,7 @@ void _ma_bitmap_reset_cache(MARIA_SHARE *share) */ bitmap->page= ((pgcache_page_no_t) 0) - bitmap->pages_covered; bitmap->used_size= bitmap->total_size= bitmap->max_total_size; + bitmap->full_head_size= bitmap->full_tail_size= bitmap->max_total_size; bfill(bitmap->map, share->block_size, 255); #ifndef DBUG_OFF memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size); @@ -1016,9 +1030,6 @@ static void adjust_total_size(MARIA_HA *info, pgcache_page_no_t page) bitmap Bitmap handler page Page to read - TODO - Update 'bitmap->used_size' to real size of used bitmap - NOTE We don't always have share->bitmap.bitmap_lock here (when called from_ma_check_bitmap_data() for example). @@ -1035,6 +1046,9 @@ static my_bool _ma_read_bitmap_page(MARIA_HA *info, MARIA_SHARE *share= info->s; my_bool res; DBUG_ENTER("_ma_read_bitmap_page"); + DBUG_PRINT("enter", ("page: %lld data_file_length: %lld", + (longlong) page, + (longlong) share->state.state.data_file_length)); DBUG_ASSERT(page % bitmap->pages_covered == 0); DBUG_ASSERT(!bitmap->changed); @@ -1049,13 +1063,22 @@ static my_bool _ma_read_bitmap_page(MARIA_HA *info, } adjust_total_size(info, page); - bitmap->used_size= bitmap->total_size; + bitmap->full_head_size= bitmap->full_tail_size= 0; DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size); res= pagecache_read(share->pagecache, &bitmap->file, page, 0, bitmap->map, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == NULL; + if (!res) + { + /* Calculate used_size */ + const uchar *data, *end= bitmap->map; + for (data= bitmap->map + bitmap->total_size; --data >= end && *data == 0; ) + {} + bitmap->used_size= (uint) ((data + 1) - end); + DBUG_ASSERT(bitmap->used_size <= bitmap->total_size); + } /* We can't check maria_bitmap_marker here as if the bitmap page previously had a true checksum and the user switched mode to not checksum @@ -1067,7 +1090,10 @@ static my_bool _ma_read_bitmap_page(MARIA_HA *info, #ifndef DBUG_OFF if (!res) + { memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size); + _ma_check_bitmap(bitmap); + } #endif DBUG_RETURN(res); } @@ -1097,6 +1123,8 @@ static my_bool _ma_change_bitmap_page(MARIA_HA *info, { DBUG_ENTER("_ma_change_bitmap_page"); + _ma_check_bitmap(bitmap); + /* We have to mark the file changed here, as otherwise the following read/write to pagecache may force a page out from this file, which would @@ -1228,6 +1256,9 @@ static void fill_block(MARIA_FILE_BITMAP *bitmap, This is defined as the first page of the set of pages with the smallest free space that can hold 'size'. + NOTES + Updates bitmap->full_head_size while scanning data + RETURN 0 ok (block is updated) 1 error (no space in bitmap; block is not touched) @@ -1238,10 +1269,11 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, MARIA_BITMAP_BLOCK *block) { uint min_bits= size_to_head_pattern(bitmap, size); - uchar *data= bitmap->map, *end= data + bitmap->used_size; + uchar *data, *end; uchar *best_data= 0; uint best_bits= (uint) -1, UNINIT_VAR(best_pos); - uint first_pattern= 0; /* if doing insert_order */ + my_bool first_pattern= 0; /* if doing insert_order */ + my_bool first_found= 1; MARIA_SHARE *share= bitmap->share; my_bool insert_order= MY_TEST(share->base.extra_options & MA_EXTRA_OPTIONS_INSERT_ORDER); @@ -1249,16 +1281,19 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, DBUG_ASSERT(size <= FULL_PAGE_SIZE(share)); + end= bitmap->map + bitmap->used_size; if (insert_order && bitmap->page == share->last_insert_bitmap) { uint last_insert_page= share->last_insert_page; uint byte= 6 * (last_insert_page / 16); first_pattern= last_insert_page % 16; - DBUG_ASSERT(data + byte < end); - data+= byte; + data= bitmap->map+byte; + DBUG_ASSERT(data <= end); } + else + data= bitmap->map + (bitmap->full_head_size/6)*6; - for (; data < end; data+= 6) + for (; data < end; data+= 6, first_pattern= 0) { ulonglong bits= uint6korr(data); /* 6 bytes = 6*8/3= 16 patterns */ uint i; @@ -1271,17 +1306,24 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, */ if ((!bits && best_data) || ((bits & 04444444444444444LL) == 04444444444444444LL)) - { - first_pattern= 0; // always restart from 0 when moving to new 6-byte continue; - } + for (i= first_pattern, bits >>= (3 * first_pattern); i < 16 ; i++, bits >>= 3) { uint pattern= (uint) (bits & 7); + + if (pattern <= 3) /* Room for more data */ + { + if (first_found) + { + first_found= 0; + bitmap->full_head_size= (data - bitmap->map); + } + } if (pattern <= min_bits) { - /* There is enough space here */ + /* There is enough space here, check if we have found better */ if ((int) pattern > (int) best_bits) { /* @@ -1292,23 +1334,32 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, best_bits= pattern; best_data= data; best_pos= i; - if (pattern == min_bits) + if (pattern == min_bits || bitmap->return_first_match) goto found; /* Best possible match */ } } } - first_pattern= 0; // always restart from 0 when moving to new 6-byte } if (!best_data) /* Found no place */ { if (data >= bitmap->map + bitmap->total_size) DBUG_RETURN(1); /* No space in bitmap */ + DBUG_ASSERT(uint6korr(data) == 0); /* Allocate data at end of bitmap */ - bitmap->used_size+= 6; - set_if_smaller(bitmap->used_size, bitmap->total_size); + bitmap->used_size= (uint) (data - bitmap->map) + 6; best_data= data; best_pos= best_bits= 0; } + else + { + /* + This is not stricly needed as used_size should be alligned on 6, + but for easier debugging lets try to keep it more accurate + */ + uint position= (uint) (best_data - bitmap->map) + 6; + set_if_bigger(bitmap->used_size, position); + } + DBUG_ASSERT(bitmap->used_size <= bitmap->total_size); found: if (insert_order) @@ -1341,12 +1392,15 @@ static my_bool allocate_tail(MARIA_FILE_BITMAP *bitmap, uint size, MARIA_BITMAP_BLOCK *block) { uint min_bits= size_to_tail_pattern(bitmap, size); - uchar *data= bitmap->map, *end= data + bitmap->used_size; - uchar *best_data= 0; + uchar *data, *end, *best_data= 0; + my_bool first_found= 1; uint best_bits= (uint) -1, UNINIT_VAR(best_pos); DBUG_ENTER("allocate_tail"); DBUG_PRINT("enter", ("size: %u", size)); + data= bitmap->map + (bitmap->full_tail_size/6)*6; + end= bitmap->map + bitmap->used_size; + /* We have to add DIR_ENTRY_SIZE here as this is not part of the data size See call to allocate_tail() in find_tail(). @@ -1375,7 +1429,19 @@ static my_bool allocate_tail(MARIA_FILE_BITMAP *bitmap, uint size, for (i= 0; i < 16; i++, bits >>= 3) { uint pattern= (uint) (bits & 7); - if (pattern <= min_bits && (!pattern || pattern >= 5)) + + if (pattern == 0 || + (pattern > FULL_HEAD_PAGE && pattern < FULL_TAIL_PAGE)) + { + /* There is room for tail data */ + if (first_found) + { + first_found= 0; + bitmap->full_tail_size= (data - bitmap->map); + } + } + + if (pattern <= min_bits && (!pattern || pattern > FULL_HEAD_PAGE)) { if ((int) pattern > (int) best_bits) { @@ -1392,10 +1458,11 @@ static my_bool allocate_tail(MARIA_FILE_BITMAP *bitmap, uint size, { if (data >= bitmap->map + bitmap->total_size) DBUG_RETURN(1); + DBUG_ASSERT(uint6korr(data) == 0); /* Allocate data at end of bitmap */ best_data= data; - bitmap->used_size+= 6; - set_if_smaller(bitmap->used_size, bitmap->total_size); + bitmap->used_size= (uint) (data - bitmap->map) + 6; + DBUG_ASSERT(bitmap->used_size <= bitmap->total_size); best_pos= best_bits= 0; } @@ -1434,8 +1501,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, ulong pages_needed, MARIA_BITMAP_BLOCK *block, my_bool full_page) { - uchar *data= bitmap->map, *data_end= data + bitmap->used_size; - uchar *page_end= data + bitmap->total_size; + uchar *data, *data_end, *page_end; uchar *best_data= 0; uint min_size; uint best_area_size, UNINIT_VAR(best_prefix_area_size); @@ -1449,6 +1515,10 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, min_size= BLOB_SEGMENT_MIN_SIZE; best_area_size= ~(uint) 0; + data= bitmap->map + (bitmap->full_head_size/6)*6; + data_end= bitmap->map + bitmap->used_size; + page_end= bitmap->map + bitmap->total_size; + for (; data < page_end; data+= 6) { ulonglong bits= uint6korr(data); /* 6 bytes = 6*8/3= 16 patterns */ @@ -1466,6 +1536,12 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, if ((bits= uint6korr(data))) break; } + /* + Check if we are end of bitmap. In this case we know that + the rest of the bitmap is usable + */ + if (data >= data_end) + data= page_end; area_size= (uint) (data - data_start) / 6 * 16; if (area_size >= best_area_size) continue; @@ -1823,7 +1899,7 @@ static my_bool allocate_blobs(MARIA_HA *info, MARIA_ROW *row) /* - Store in the bitmap the new size for a head page + Reserve the current head page SYNOPSIS use_head() @@ -2225,7 +2301,7 @@ static my_bool set_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, pgcache_page_no_t page, uint fill_pattern) { pgcache_page_no_t bitmap_page; - uint offset_page, offset, tmp, org_tmp; + uint offset_page, offset, tmp, org_tmp, used_offset; uchar *data; DBUG_ENTER("set_page_bits"); DBUG_ASSERT(fill_pattern <= 7); @@ -2237,6 +2313,7 @@ static my_bool set_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, /* Find page number from start of bitmap */ offset_page= (uint) (page - bitmap->page - 1); + /* Mark place used by reading/writing 2 bytes at a time to handle bitmaps in overlapping bytes @@ -2248,11 +2325,37 @@ static my_bool set_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, tmp= (tmp & ~(7 << offset)) | (fill_pattern << offset); if (tmp == org_tmp) DBUG_RETURN(0); /* No changes */ - int2store(data, tmp); + /* + Take care to not write bytes outside of bitmap. + fill_pattern is 3 bits, so we need to write two bytes + if bit position we write to is > (8-3) + */ + if (offset > 5) + int2store(data, tmp); + else + data[0]= tmp; + + /* + Reset full_head_size or full_tail_size if we are releasing data before + it. Increase used_size if we are allocating data. + */ + used_offset= (uint) (data - bitmap->map); + if (fill_pattern < 4) + set_if_smaller(bitmap->full_head_size, used_offset); + if (fill_pattern == 0 || (fill_pattern > 4 && fill_pattern < 7)) + set_if_smaller(bitmap->full_tail_size, used_offset); + if (fill_pattern != 0) + { + /* Calulcate which was the last changed byte */ + used_offset+= offset > 5 ? 2 : 1; + set_if_bigger(bitmap->used_size, used_offset); + } + + _ma_check_bitmap(bitmap); bitmap->changed= 1; DBUG_EXECUTE("bitmap", _ma_print_bitmap_changes(bitmap);); - if (fill_pattern != 3 && fill_pattern != 7) + if (fill_pattern != FULL_HEAD_PAGE && fill_pattern != FULL_TAIL_PAGE) set_if_smaller(info->s->state.first_bitmap_with_space, bitmap_page); /* Note that if the condition above is false (page is full), and all pages of @@ -2345,7 +2448,7 @@ my_bool _ma_bitmap_reset_full_page_bits(MARIA_HA *info, uint page_count) { ulonglong bitmap_page; - uint offset, bit_start, bit_count, tmp; + uint offset, bit_start, bit_count, tmp, byte_offset; uchar *data; DBUG_ENTER("_ma_bitmap_reset_full_page_bits"); DBUG_PRINT("enter", ("page: %lu page_count: %u", (ulong) page, page_count)); @@ -2365,7 +2468,8 @@ my_bool _ma_bitmap_reset_full_page_bits(MARIA_HA *info, bit_start= offset * 3; bit_count= page_count * 3; - data= bitmap->map + bit_start / 8; + byte_offset= bit_start/8; + data= bitmap->map + byte_offset; offset= bit_start & 7; tmp= (255 << offset); /* Bits to keep */ @@ -2376,6 +2480,9 @@ my_bool _ma_bitmap_reset_full_page_bits(MARIA_HA *info, } *data&= ~tmp; + set_if_smaller(bitmap->full_head_size, byte_offset); + set_if_smaller(bitmap->full_tail_size, byte_offset); + if ((int) (bit_count-= (8 - offset)) > 0) { uint fill; @@ -2477,6 +2584,8 @@ my_bool _ma_bitmap_set_full_page_bits(MARIA_HA *info, tmp= (1 << bit_count) - 1; *data|= tmp; } + set_if_bigger(bitmap->used_size, (uint) (data - bitmap->map) + 1); + _ma_check_bitmap(bitmap); bitmap->changed= 1; DBUG_EXECUTE("bitmap", _ma_print_bitmap_changes(bitmap);); DBUG_RETURN(0); @@ -2835,6 +2944,72 @@ my_bool _ma_check_bitmap_data(MARIA_HA *info, enum en_page_type page_type, return (bitmap_pattern != bits); } +/** + Check that bitmap looks correct + + - All data before full_head_size and full_tail_size are allocated + - There is no allocated data after used_size + All of the above need to be correct only according to 6 byte + alignment as all loops reads 6 bytes at a time and we check both + start and end position according to the current 6 byte position. +*/ + +#ifndef DBUG_OFF +static void _ma_check_bitmap(MARIA_FILE_BITMAP *bitmap) +{ + uchar *data= bitmap->map; + uchar *end= bitmap->map + bitmap->total_size; + uchar *full_head_end=0, *full_tail_end=0, *first_empty= bitmap->map; + + for (; data < end; data+= 6) + { + ulonglong bits= uint6korr(data); /* 6 bytes = 6*8/3= 16 patterns */ + uint i; + + if (bits == 04444444444444444LL || bits == 0xffffffffffffLL) + { + first_empty= data + 6; + continue; /* block fully used */ + } + if (bits == 0) + { + if (!full_head_end) + full_head_end= data; + if (!full_tail_end) + full_tail_end= data; + continue; + } + + first_empty= data + 6; + if (!full_head_end || !full_tail_end) + { + for (i= 0, bits >>= 0; i < 16 ; i++, bits >>= 3) + { + uint pattern= (uint) (bits & 7); + if (pattern == FULL_HEAD_PAGE || pattern == FULL_TAIL_PAGE) + continue; + + if (pattern < 4 && !full_head_end) + full_head_end= data; + if ((pattern == 0 || (pattern > 4 && pattern < 7)) && !full_tail_end) + full_tail_end= data; + } + } + } + if (!full_head_end) + full_head_end= data; + if (!full_tail_end) + full_tail_end= data; + + /* used_size must point after the last byte that had some data) */ + DBUG_ASSERT(bitmap->used_size <= bitmap->total_size); + DBUG_ASSERT((bitmap->map + (bitmap->used_size+5)/6*6) >= first_empty); + /* full_xxxx_size can't point after the first block that has free data */ + DBUG_ASSERT((bitmap->map + (bitmap->full_head_size/6*6)) <= full_head_end); + DBUG_ASSERT((bitmap->map + (bitmap->full_tail_size/6*6)) <= full_tail_end); +} +#endif + /* Check if the page type matches the one that we have in the bitmap @@ -3072,6 +3247,7 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info, pgcache_page_no_t from, to; my_off_t data_file_length= share->state.state.data_file_length; DBUG_ENTER("_ma_bitmap_create_missing"); + DBUG_PRINT("enter", ("page: %lld", (longlong) page)); /* First (in offset order) bitmap page to create */ if (data_file_length < block_size) @@ -3124,7 +3300,8 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info, only later as we are going to modify it very soon. */ bzero(bitmap->map, bitmap->block_size); - bitmap->used_size= 0; + bitmap->used_size= bitmap->full_head_size= bitmap->full_tail_size= 0; + bitmap->changed=1; #ifndef DBUG_OFF /* Make a copy of the page to be able to print out bitmap changes during diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index c4ec3cf2f9adfa9c02e4e6d98eb00fd2a2160bec..c0a9341537960bfbfd812530a5ed82784e80de2b 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -271,6 +271,7 @@ #include "maria_def.h" #include "ma_blockrec.h" #include "trnman.h" +#include "ma_trnman.h" #include "ma_key_recover.h" #include "ma_recovery_util.h" #include @@ -7525,7 +7526,7 @@ void maria_ignore_trids(MARIA_HA *info) if (info->s->base.born_transactional) { if (!info->trn) - _ma_set_trn_for_table(info, &dummy_transaction_object); + _ma_set_tmp_trn_for_table(info, &dummy_transaction_object); /* Ignore transaction id when row is read */ info->trn->min_read_from= ~(TrID) 0; } diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index d89a69f02abacf599ca42c83d8608493930cc08a..b63340e23a6e1119150c04437c55caddc6114c26 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -37,6 +37,8 @@ int maria_close(register MARIA_HA *info) /* Check that we have unlocked key delete-links properly */ DBUG_ASSERT(info->key_del_used == 0); + /* Check that file is not part of any uncommited transactions */ + DBUG_ASSERT(info->trn == 0 || info->trn == &dummy_transaction_object); if (share->reopen == 1) { diff --git a/storage/maria/ma_commit.c b/storage/maria/ma_commit.c index 358f564d3f1fc858201012049732ff64bcd8db15..0ae3868dbf64d5baa5fcc35ea22fc9fecc878f7d 100644 --- a/storage/maria/ma_commit.c +++ b/storage/maria/ma_commit.c @@ -15,6 +15,7 @@ #include "maria_def.h" #include "trnman.h" +#include "ma_trnman.h" /** writes a COMMIT record to log and commits transaction in memory @@ -43,9 +44,9 @@ int ma_commit(TRN *trn) COMMIT record) and this is not an issue as * transaction's updates were not made visible to other transactions * "commit ok" was not sent to client - Alternatively, Recovery might commit trn (if MY_MIN(rec_lsn) is before COMMIT - record), which is ok too. All in all it means that "trn committed" is not - 100% equal to "COMMIT record written". + Alternatively, Recovery might commit trn (if MY_MIN(rec_lsn) is before + COMMIT record), which is ok too. All in all it means that "trn committed" + is not 100% equal to "COMMIT record written". - if COMMIT record is written after trnman_commit_trn(): if crash happens between the two, trn will be rolled back which is an issue (transaction's updates were made visible to other transactions). @@ -93,7 +94,12 @@ int ma_commit(TRN *trn) int maria_commit(MARIA_HA *info) { - return info->s->now_transactional ? ma_commit(info->trn) : 0; + TRN *trn; + if (!info->s->now_transactional) + return 0; + trn= info->trn; + info->trn= 0; /* checked in maria_close() */ + return ma_commit(trn); } @@ -120,10 +126,7 @@ int maria_begin(MARIA_HA *info) TRN *trn= trnman_new_trn(0); if (unlikely(!trn)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - DBUG_PRINT("info", ("TRN set to 0x%lx", (ulong) trn)); _ma_set_trn_for_table(info, trn); } DBUG_RETURN(0); } - diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c index b46cf7e176516f9bbb4616e1bb25bba247fbc45c..f037589db29b42e6f4ce20b73cf4ddc9f462dc8a 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -273,7 +273,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing, " file is probably in use by another process"; uint new_cf_create_time_size, new_cf_changeable_size, new_block_size; my_off_t file_size; - int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR; + int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR | O_CLOEXEC; int error= CONTROL_FILE_UNKNOWN_ERROR; DBUG_ENTER("ma_control_file_open"); diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index 7f34b73089f91ef496ca9e8a44ed4b86ad5769aa..0234eb5fb7f326b440621a3caf652f9daeccf4f3 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -275,7 +275,7 @@ my_bool _ma_update_blob_record(MARIA_HA *info, MARIA_RECORD_POS pos, { uchar *rec_buff; int error; - ulong reclength,extra; + ulong reclength,reclength2,extra; extra= (ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER)+MARIA_SPLIT_LENGTH+ MARIA_DYN_DELETE_BLOCK_HEADER); @@ -293,11 +293,12 @@ my_bool _ma_update_blob_record(MARIA_HA *info, MARIA_RECORD_POS pos, my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ return(1); } - reclength= _ma_rec_pack(info,rec_buff+ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER), + reclength2= _ma_rec_pack(info,rec_buff+ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER), record); + DBUG_ASSERT(reclength2 <= reclength); error=update_dynamic_record(info,pos, rec_buff+ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER), - reclength); + reclength2); my_safe_afree(rec_buff, reclength); return(error != 0); } diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 6c74bb52f513adf1d79448ab127d121f88585cbc..f3800bc36bef660718f6897f81049d6b4ac7a405 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -345,7 +345,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, _ma_decrement_open_count(info, 0); if (info->trn) { - _ma_remove_table_from_trnman(share, info->trn); + _ma_remove_table_from_trnman(info); /* Ensure we don't point to the deleted data in trn */ info->state= info->state_start= &share->state.state; } @@ -408,7 +408,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, if (info->trn) { mysql_mutex_lock(&share->intern_lock); - _ma_remove_table_from_trnman(share, info->trn); + _ma_remove_table_from_trnman(info); /* Ensure we don't point to the deleted data in trn */ info->state= info->state_start= &share->state.state; mysql_mutex_unlock(&share->intern_lock); diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 129770249aacf958ba63109adaaaad8068bd5035..aa7ff9da7f2f134cddb21498420e0869b86c5702 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -935,7 +935,7 @@ static File create_logfile_by_number_no_cache(uint32 file_no) /* TODO: add O_DIRECT to open flags (when buffer is aligned) */ if ((file= mysql_file_create(key_file_translog, translog_filename_by_fileno(file_no, path), - 0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0) + 0, O_BINARY | O_RDWR | O_CLOEXEC, MYF(MY_WME))) < 0) { DBUG_PRINT("error", ("Error %d during creating file '%s'", errno, path)); translog_stop_writing(); @@ -973,7 +973,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no) /* TODO: use mysql_file_create() */ if ((file= mysql_file_open(key_file_translog, translog_filename_by_fileno(file_no, path), - log_descriptor.open_flags, + log_descriptor.open_flags | O_CLOEXEC, MYF(MY_WME))) < 0) { DBUG_PRINT("error", ("Error %d during opening file '%s'", errno, path)); @@ -3243,7 +3243,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr, File fd; if ((fd= mysql_file_open(key_file_translog, translog_filename_by_fileno(file_no, path), - O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0) + O_RDONLY | O_CLOEXEC, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0) { my_errno= errno; DBUG_PRINT("error", ("Error %d during opening file #%d", diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index c4a7df4443c7495c0806cd5991871e4efc249189..598f76a6472d134f01a6494b5f95f6055a8b7328 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -19,6 +19,8 @@ #include "ma_sp_defs.h" #include "ma_rt_index.h" #include "ma_blockrec.h" +#include "trnman.h" +#include "ma_trnman.h" #include #include "ma_crypt.h" @@ -184,7 +186,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, if (!share->base.born_transactional) /* For transactional ones ... */ { /* ... force crash if no trn given */ - _ma_set_trn_for_table(&info, &dummy_transaction_object); + _ma_set_tmp_trn_for_table(&info, &dummy_transaction_object); info.state= &share->state.state; /* Change global values by default */ } else @@ -332,13 +334,13 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) }); DEBUG_SYNC_C("mi_open_kfile"); if ((kfile=mysql_file_open(key_file_kfile, name_buff, - (open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW, + (open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW | O_CLOEXEC, MYF(MY_NOSYMLINKS))) < 0) { if ((errno != EROFS && errno != EACCES) || mode != O_RDONLY || (kfile=mysql_file_open(key_file_kfile, name_buff, - (open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW, + (open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW | O_CLOEXEC, MYF(MY_NOSYMLINKS))) < 0) goto err; } @@ -1940,7 +1942,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share) DEBUG_SYNC_C("mi_open_datafile"); info->dfile.file= share->bitmap.file.file= mysql_file_open(key_file_dfile, share->data_file_name.str, - share->mode | O_SHARE, MYF(flags)); + share->mode | O_SHARE | O_CLOEXEC, MYF(flags)); return info->dfile.file >= 0 ? 0 : 1; } @@ -1954,7 +1956,7 @@ int _ma_open_keyfile(MARIA_SHARE *share) mysql_mutex_lock(&share->intern_lock); share->kfile.file= mysql_file_open(key_file_kfile, share->unique_file_name.str, - share->mode | O_SHARE | O_NOFOLLOW, + share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC, MYF(MY_WME | MY_NOSYMLINKS)); mysql_mutex_unlock(&share->intern_lock); return (share->kfile.file < 0); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index b0b547a3070784e7df08757fd8939443dd88c6b9..c06e46c104f272cc7311f07294ca145a7bf50fa0 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3520,6 +3520,14 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info, { MARIA_SHARE *share= info->s; DBUG_ENTER("_ma_tmp_disable_logging_for_table"); + + /* + We have to ensure that bitmap is flushed, as it's checking + that share->now_transactional is set + */ + if (share->now_transactional && share->data_file_type == BLOCK_RECORD) + _ma_bitmap_flush_all(share); + if (log_incomplete) { uchar log_data[FILEID_STORE_SIZE]; @@ -3583,7 +3591,10 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages) if (share->now_transactional == share->base.born_transactional || !info->switched_transactional) + { + info->switched_transactional= FALSE; DBUG_RETURN(0); + } info->switched_transactional= FALSE; if ((share->now_transactional= share->base.born_transactional)) diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 7404fe06641c674dfa6512ddf8fa2c90c002d398..aeefd9aa190acb85abc11cbc868fe7a7df9a75e3 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -66,7 +66,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info) DBUG_RETURN(1); trn= info->trn; - for (tables= (MARIA_USED_TABLES*) info->trn->used_tables; + for (tables= (MARIA_USED_TABLES*) trn->used_tables; tables; tables= tables->next) { @@ -551,6 +551,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit, my_free(tables); } trn->used_tables= 0; + trn->used_instances= 0; DBUG_RETURN(error); } @@ -565,18 +566,25 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit, share->internal_lock must be locked when function is called */ -void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn) +void _ma_remove_table_from_trnman(MARIA_HA *info) { + MARIA_SHARE *share= info->s; + TRN *trn= info->trn; MARIA_USED_TABLES *tables, **prev; + MARIA_HA *handler, **prev_file; DBUG_ENTER("_ma_remove_table_from_trnman"); DBUG_PRINT("enter", ("trn: %p used_tables: %p share: %p in_trans: %d", trn, trn->used_tables, share, share->in_trans)); mysql_mutex_assert_owner(&share->intern_lock); + + if (trn == &dummy_transaction_object) + DBUG_VOID_RETURN; - for (prev= (MARIA_USED_TABLES**) (char*) &trn->used_tables, tables= *prev; - tables; - tables= *prev) + /* First remove share from used_tables */ + for (prev= (MARIA_USED_TABLES**) (char*) &trn->used_tables; + (tables= *prev); + prev= &tables->next) { if (tables->share == share) { @@ -585,8 +593,36 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn) my_free(tables); break; } - prev= &tables->next; } + if (tables != 0) + { + /* + This can only happens in case of rename of intermediate table as + part of alter table + */ + DBUG_PRINT("warning", ("share: %p where not in used_tables_list", share)); + } + + /* unlink table from used_instances */ + for (prev_file= (MARIA_HA**) &trn->used_instances; + (handler= *prev_file); + prev_file= &handler->trn_next) + { + if (handler == info) + { + *prev_file= info->trn_next; + break; + } + } + if (handler != 0) + { + /* + This can only happens in case of rename of intermediate table as + part of alter table + */ + DBUG_PRINT("warning", ("table: %p where not in used_instances", info)); + } + info->trn= 0; /* Not part of trans anymore */ DBUG_VOID_RETURN; } diff --git a/storage/maria/ma_state.h b/storage/maria/ma_state.h index a86aada94fd393c3713da888b1a24262a90094ff..8728a2113e59341530259d62bea3a2abe98df880 100644 --- a/storage/maria/ma_state.h +++ b/storage/maria/ma_state.h @@ -84,5 +84,5 @@ my_bool _ma_row_visible_non_transactional_table(MARIA_HA *info); my_bool _ma_row_visible_transactional_table(MARIA_HA *info); void _ma_remove_not_visible_states_with_lock(struct st_maria_share *share, my_bool all); -void _ma_remove_table_from_trnman(struct st_maria_share *share, TRN *trn); +void _ma_remove_table_from_trnman(MARIA_HA *info); void _ma_reset_history(struct st_maria_share *share); diff --git a/storage/maria/ma_trnman.h b/storage/maria/ma_trnman.h new file mode 100644 index 0000000000000000000000000000000000000000..9bfd1f0d0479b3476ae953dd896adf32a654a97c --- /dev/null +++ b/storage/maria/ma_trnman.h @@ -0,0 +1,65 @@ +/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef _ma_trnman_h +#define _ma_trnman_h + +/** + Sets table's trn and prints debug information + Links table into used_instances if new_trn is not 0 + + @param tbl MARIA_HA of table + @param newtrn what to put into tbl->trn +*/ + +static inline void _ma_set_trn_for_table(MARIA_HA *tbl, TRN *newtrn) +{ + DBUG_PRINT("info",("table: %p trn: %p -> %p", + tbl, tbl->trn, newtrn)); + + /* check that we are not calling this twice in a row */ + DBUG_ASSERT(newtrn->used_instances != (void*) tbl); + + tbl->trn= newtrn; + /* Link into used list */ + tbl->trn_next= (MARIA_HA*) newtrn->used_instances; + newtrn->used_instances= tbl; +} + + +/* + Same as _ma_set_trn_for_table(), but don't link table into used_instance list + Used when we want to temporary set trn for a table in extra() +*/ + +static inline void _ma_set_tmp_trn_for_table(MARIA_HA *tbl, TRN *newtrn) +{ + DBUG_PRINT("info",("table: %p trn: %p -> %p", + tbl, tbl->trn, newtrn)); + tbl->trn= newtrn; +} + + +/* + Reset TRN in table +*/ + +static inline void _ma_reset_trn_for_table(MARIA_HA *tbl) +{ + DBUG_PRINT("info",("table: %p trn: %p -> NULL", tbl, tbl->trn)); + tbl->trn= 0; +} + +#endif /* _ma_trnman_h */ diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index aa01f4cd8957d8ffbd861580c5e45d0d173063d4..b47f1b8c82441ea901a271021a5349ec5f3493d0 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -895,7 +895,7 @@ static void get_options(register int *argc,register char ***argv) { int ho_error; - load_defaults("my", load_default_groups, argc, argv); + load_defaults_or_exit("my", load_default_groups, argc, argv); default_argv= *argv; check_param.testflag= T_UPDATE_STATE; if (isatty(fileno(stdout))) diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index d57a429365a76cfe770407fb0f01d4e479e14c4a..8262e1b5e2dd643470b4432001f31ef4d639df6a 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -331,7 +331,10 @@ typedef struct st_maria_file_bitmap pgcache_page_no_t last_bitmap_page; /* Last possible bitmap page */ my_bool changed; /* 1 if page needs to be written */ my_bool changed_not_flushed; /* 1 if some bitmap is not flushed */ + my_bool return_first_match; /* Shortcut find_head() */ uint used_size; /* Size of bitmap head that is not 0 */ + uint full_head_size; /* Where to start search for head */ + uint full_tail_size; /* Where to start search for tail */ uint flush_all_requested; /**< If _ma_bitmap_flush_all waiting */ uint waiting_for_flush_all_requested; /* If someone is waiting for above */ uint non_flushable; /**< 0 if bitmap and log are in sync */ @@ -598,6 +601,7 @@ struct st_maria_handler { MARIA_SHARE *s; /* Shared between open:s */ struct st_ma_transaction *trn; /* Pointer to active transaction */ + struct st_maria_handler *trn_next; MARIA_STATUS_INFO *state, state_save; MARIA_STATUS_INFO *state_start; /* State at start of transaction */ MARIA_USED_TABLES *used_tables; @@ -857,19 +861,6 @@ struct st_maria_handler #define get_pack_length(length) ((length) >= 255 ? 3 : 1) #define _ma_have_versioning(info) ((info)->row_flag & ROW_FLAG_TRANSID) -/** - Sets table's trn and prints debug information - @param tbl MARIA_HA of table - @param newtrn what to put into tbl->trn - @note cast of newtrn is because %p of NULL gives warning (NULL is int) -*/ -#define _ma_set_trn_for_table(tbl, newtrn) do { \ - DBUG_PRINT("info",("table: %p trn: %p -> %p", \ - (tbl), (tbl)->trn, (void *)(newtrn))); \ - (tbl)->trn= (newtrn); \ - } while (0) - - #define MARIA_MIN_BLOCK_LENGTH 20 /* Because of delete-link */ /* Don't use to small record-blocks */ #define MARIA_EXTEND_BLOCK_LENGTH 20 diff --git a/storage/maria/maria_dump_log.c b/storage/maria/maria_dump_log.c index 42c694bf1bfe5196908e5b8df6e2dcc074b72c1b..3570dede80ecad8d07ba67f088fa71593d3348d5 100644 --- a/storage/maria/maria_dump_log.c +++ b/storage/maria/maria_dump_log.c @@ -133,7 +133,7 @@ int main(int argc, char **argv) uchar buffer[TRANSLOG_PAGE_SIZE]; MY_INIT(argv[0]); - load_defaults("my", load_default_groups, &argc, &argv); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc, &argv); diff --git a/storage/maria/maria_pack.c b/storage/maria/maria_pack.c index 814c50e1db8a26ed90e75c77f09d574de04a4671..28b4ff4cfc70844261f320663565c1958b912e3a 100644 --- a/storage/maria/maria_pack.c +++ b/storage/maria/maria_pack.c @@ -208,7 +208,7 @@ int main(int argc, char **argv) char **default_argv; MY_INIT(argv[0]); - load_defaults("my",load_default_groups,&argc,&argv); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc,&argv); maria_init(); diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c index a0724b2199ba18541f5d23cfd571c678f3ce5704..d0cf7521e9b4e061dc5bf943d662b653cfb08a61 100644 --- a/storage/maria/maria_read_log.c +++ b/storage/maria/maria_read_log.c @@ -47,7 +47,7 @@ int main(int argc, char **argv) maria_data_root= (char *)"."; sf_leaking_memory=1; /* don't report memory leaks on early exits */ - load_defaults("my", load_default_groups, &argc, &argv); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc, &argv); diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c index bc48d39baaa6b231ea4220a33f76aeed9ce5e93c..5b3c9f0287a71350e3ab61afec1bdfdd9b599938 100644 --- a/storage/maria/trnman.c +++ b/storage/maria/trnman.c @@ -357,6 +357,7 @@ TRN *trnman_new_trn(WT_THD *wt) trn->commit_trid= MAX_TRID; trn->rec_lsn= trn->undo_lsn= trn->first_undo_lsn= 0; trn->used_tables= 0; + trn->used_instances= 0; trn->locked_tables= 0; trn->flags= 0; diff --git a/storage/maria/trnman.h b/storage/maria/trnman.h index 66139a31230fb5a49e1ad9eb05b7a3cf34009b2b..11c7379776636253098c1b3f4b2199923388d297 100644 --- a/storage/maria/trnman.h +++ b/storage/maria/trnman.h @@ -46,7 +46,8 @@ struct st_ma_transaction LF_PINS *pins; WT_THD *wt; mysql_mutex_t state_lock; - void *used_tables; /**< Tables used by transaction */ + void *used_tables; /**< Table shares used by transaction */ + void *used_instances; /* table files used by transaction */ TRN *next, *prev; TrID trid, min_read_from, commit_trid; LSN rec_lsn, undo_lsn; diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index 1ea31d228e1f9825772acfd78014d2db4df2f67f..dc7e0c79f87d95aaede3913a1b8b27df360e829b 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -256,7 +256,7 @@ int main(int argc __attribute__((unused)), char *argv[]) #endif long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); - load_defaults("my", load_default_groups, &argc, &argv); + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc, &argv); diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt index 5d8e8c1eeb83bcf21233c754664a8ea06eeff542..5a7d4699386654b93a233e26731c0816fb6d5fc9 100644 --- a/storage/mroonga/CMakeLists.txt +++ b/storage/mroonga/CMakeLists.txt @@ -315,6 +315,9 @@ if(MRN_BUNDLED) ${MRN_ALL_SOURCES} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES ${MRN_LIBRARIES}) + if(NOT TARGET mroonga) + return() + endif() else() add_library(mroonga MODULE ${MRN_ALL_SOURCES}) diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index e27070f9e0c3120c6b31e1093cc564be3ab51be7..ee526646c092a50b73f345ce7355aa8ca7e6a077 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -361,10 +361,18 @@ if(NOT ${GRN_WITH_LZ4} STREQUAL "no") pkg_check_modules(LIBLZ4 liblz4) endif() if(LIBLZ4_FOUND) + # According to CMake documentation, this is the recommended way to force + # looking in LIBRARY_DIRS first and in regular system paths otherwise. + # + # pkg_check_modules does not guarantee that LIBLZ4_LIBRARY_DIRS will be + # set. If it's not set we won't find the library without looking through + # the regular system paths. find_library(LZ4_LIBS - NAMES ${LIBLZ4_LIBRARIES} - PATHS ${LIBLZ4_LIBRARY_DIRS} - NO_DEFAULT_PATH) + NAMES ${LIBLZ4_LIBRARIES} + PATHS ${LIBLZ4_LIBRARY_DIRS} + NO_DEFAULT_PATH) + find_library(LZ4_LIBS + NAMES ${LIBLZ4_LIBRARIES}) set(GRN_WITH_LZ4 TRUE) else() if(${GRN_WITH_LZ4} STREQUAL "yes") diff --git a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt index 6765261feb7da9184066e780f3ad5bfb9bf1602f..64fadb8bbdd0bd2e2bb9421ae5ca244408f120e2 100644 --- a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt @@ -177,3 +177,9 @@ if(GRN_WITH_MRUBY) FILES ${EXPRESSION_TREE_RUBY_SCRIPTS} DESTINATION "${GRN_RELATIVE_RUBY_SCRIPTS_DIR}/expression_tree") endif() + +# Workaround GCC ICE on ARM64 +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER "5") + ADD_COMPILE_FLAGS(ts/ts_expr_node.c COMPILE_FLAGS "-fno-tree-loop-vectorize") +ENDIF() diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 7f2afc3130a608811a89fa9ebe33614652388db2..92888e0321e3aafba491c196272e1370b4bb90c3 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -2470,7 +2470,7 @@ maria_declare_plugin(myisam) &myisam_storage_engine, "MyISAM", "MySQL AB", - "MyISAM storage engine", + "Non-transactional engine with good performance and small data footprint", PLUGIN_LICENSE_GPL, myisam_init, /* Plugin Init */ NULL, /* Plugin Deinit */ diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index a82f2b9e8c123a1017b2d8bda1368c95bcac87a1..e692f31b2b45be3bf716383d0fd8e4957df37265 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -139,13 +139,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) DEBUG_SYNC_C("mi_open_kfile"); if ((kfile= mysql_file_open(mi_key_file_kfile, name_buff, - (open_mode= O_RDWR) | O_SHARE | O_NOFOLLOW, + (open_mode= O_RDWR) | O_SHARE | O_NOFOLLOW | O_CLOEXEC, MYF(MY_NOSYMLINKS))) < 0) { if ((errno != EROFS && errno != EACCES) || mode != O_RDONLY || (kfile= mysql_file_open(mi_key_file_kfile, name_buff, - (open_mode= O_RDONLY) | O_SHARE| O_NOFOLLOW, + (open_mode= O_RDONLY) | O_SHARE| O_NOFOLLOW | O_CLOEXEC, MYF(MY_NOSYMLINKS))) < 0) goto err; } @@ -1273,7 +1273,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS: 0); DEBUG_SYNC_C("mi_open_datafile"); info->dfile= mysql_file_open(mi_key_file_dfile, share->data_file_name, - share->mode | O_SHARE, MYF(flags)); + share->mode | O_SHARE | O_CLOEXEC, MYF(flags)); return info->dfile >= 0 ? 0 : 1; } @@ -1282,7 +1282,7 @@ int mi_open_keyfile(MYISAM_SHARE *share) { if ((share->kfile= mysql_file_open(mi_key_file_kfile, share->unique_file_name, - share->mode | O_SHARE | O_NOFOLLOW, + share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC, MYF(MY_NOSYMLINKS | MY_WME))) < 0) return 1; return 0; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index edbe235e190850c6939b8434b8726ed3a9c7d5ee..dfff5720847cc704973c42d77c040dd62503ea87 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -753,9 +753,7 @@ static void get_options(register int *argc,register char ***argv) { int ho_error; - if (load_defaults("my", load_default_groups, argc, argv)) - exit(1); - + load_defaults_or_exit("my", load_default_groups, argc, argv); default_argv= *argv; if (isatty(fileno(stdout))) check_param.testflag|=T_WRITE_LOOP; diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 966edc877cdbb510d5aa8d15d87cbae37c9589a4..bb9f59f86f737f4828f97dc47033841624a51877 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -209,9 +209,7 @@ int main(int argc, char **argv) char **default_argv; MY_INIT(argv[0]); - if (load_defaults("my",load_default_groups,&argc,&argv)) - exit(1); - + load_defaults_or_exit("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc,&argv); diff --git a/storage/oqgraph/graphcore-config.h b/storage/oqgraph/graphcore-config.h index 2afb7dfbcd64354e27447f3ac97c3ac255134745..3ef9da152ad9af988660562e407a557628b04799 100644 --- a/storage/oqgraph/graphcore-config.h +++ b/storage/oqgraph/graphcore-config.h @@ -27,6 +27,8 @@ #define BOOST_ALL_NO_LIB 1 #define BOOST_NO_RTTI 1 #define BOOST_NO_TYPEID 1 +#define BOOST_NO_HASH 1 +#define BOOST_NO_SLIST 1 #ifdef DBUG_OFF #define NDEBUG 1 diff --git a/storage/oqgraph/graphcore-graph.cc b/storage/oqgraph/graphcore-graph.cc index 6decce601fe4d9b879ec14e0f7cced8d673fb9d8..42366787340a81ad0f817d45e77f53161695e7d6 100644 --- a/storage/oqgraph/graphcore-graph.cc +++ b/storage/oqgraph/graphcore-graph.cc @@ -22,6 +22,5 @@ ====================================================================== */ -#include "graphcore-config.h" #include "graphcore-graph.h" diff --git a/storage/oqgraph/graphcore.cc b/storage/oqgraph/graphcore.cc index bf454aa33330cef6cc2d1ba0b18719490fc4cdc4..1a7df6147e796b3b09b48e6114e4abaab5ed0260 100644 --- a/storage/oqgraph/graphcore.cc +++ b/storage/oqgraph/graphcore.cc @@ -25,7 +25,6 @@ #include #include -#include "graphcore-config.h" #include "graphcore-graph.h" #include diff --git a/storage/oqgraph/oqgraph_shim.h b/storage/oqgraph/oqgraph_shim.h index f24732af4ef97cd310a3adce80604fe2d69de3b7..aab6e797306df5f6d66e29500b3edbc219869463 100644 --- a/storage/oqgraph/oqgraph_shim.h +++ b/storage/oqgraph/oqgraph_shim.h @@ -24,11 +24,8 @@ #pragma once -#include "oqgraph_thunk.h" #include "oqgraph_judy.h" - -#define BOOST_NO_HASH 1 -#define BOOST_NO_SLIST 1 +#include "oqgraph_thunk.h" #include #include diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 971f0c46be8063574e5763d3a5ccd1ae23b43f1e..cdbbc022d5089473018b39a30d5c1c0f3b954d57 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -225,7 +225,7 @@ maria_declare_plugin(perfschema) 0x0001, pfs_status_vars, NULL, - "5.6.36", + "5.6.40", MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 5308f780e0e9223ee292d3805b55a06f24cfabd1..3f6770b5d26c4df31daf708865d54c5a144dabf6 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -17,7 +17,7 @@ #pragma implementation // gcc: Class implementation #endif -#if _MSC_VER>=1400 +#if defined(_MSC_VER) && _MSC_VER>=1400 #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 #endif @@ -64,7 +64,7 @@ #define MSG_WAITALL 0 #endif -#if _MSC_VER>=1400 +#if defined(_MSC_VER) && _MSC_VER>=1400 #pragma warning(push,4) #endif @@ -1041,8 +1041,8 @@ static bool ParseUrl ( CSphSEShare * share, TABLE * table, bool bCreate ) bool bOk = true; bool bQL = false; char * sScheme = NULL; - char * sHost = SPHINXAPI_DEFAULT_HOST; - char * sIndex = SPHINXAPI_DEFAULT_INDEX; + char * sHost = (char*) SPHINXAPI_DEFAULT_HOST; + char * sIndex = (char*) SPHINXAPI_DEFAULT_INDEX; int iPort = SPHINXAPI_DEFAULT_PORT; // parse connection string, if any @@ -1068,12 +1068,12 @@ static bool ParseUrl ( CSphSEShare * share, TABLE * table, bool bCreate ) sHost--; // reuse last slash iPort = 0; if (!( sIndex = strrchr ( sHost, ':' ) )) - sIndex = SPHINXAPI_DEFAULT_INDEX; + sIndex = (char*) SPHINXAPI_DEFAULT_INDEX; else { *sIndex++ = '\0'; if ( !*sIndex ) - sIndex = SPHINXAPI_DEFAULT_INDEX; + sIndex = (char*) SPHINXAPI_DEFAULT_INDEX; } bOk = true; break; @@ -1095,7 +1095,7 @@ static bool ParseUrl ( CSphSEShare * share, TABLE * table, bool bCreate ) if ( sIndex ) *sIndex++ = '\0'; else - sIndex = SPHINXAPI_DEFAULT_INDEX; + sIndex = (char*) SPHINXAPI_DEFAULT_INDEX; iPort = atoi(sPort); if ( !iPort ) @@ -1107,7 +1107,7 @@ static bool ParseUrl ( CSphSEShare * share, TABLE * table, bool bCreate ) if ( sIndex ) *sIndex++ = '\0'; else - sIndex = SPHINXAPI_DEFAULT_INDEX; + sIndex = (char*) SPHINXAPI_DEFAULT_INDEX; } bOk = true; break; @@ -1303,8 +1303,8 @@ CSphSEQuery::CSphSEQuery ( const char * sQuery, int iLength, const char * sIndex , m_sGeoLongAttr ( "" ) , m_fGeoLatitude ( 0.0f ) , m_fGeoLongitude ( 0.0f ) - , m_sComment ( "" ) - , m_sSelect ( "*" ) + , m_sComment ( (char*) "" ) + , m_sSelect ( (char*) "*" ) , m_pBuf ( NULL ) , m_pCur ( NULL ) @@ -1738,7 +1738,7 @@ bool CSphSEQuery::ParseField ( char * sField ) } } else if ( !strcmp ( sName, "override" ) ) // name,type,id:value,id:value,... { - char * sName = NULL; + sName = NULL; int iType = 0; CSphSEQuery::Override_t * pOverride = NULL; @@ -1794,7 +1794,7 @@ bool CSphSEQuery::ParseField ( char * sField ) *sRest++ = '\0'; if (!( sRest - sId )) break; - char * sValue = sRest; + sValue = sRest; if ( ( sRest = strchr ( sRest, ',' ) )!=NULL ) *sRest++ = '\0'; if ( !*sValue ) @@ -2213,7 +2213,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) } char sError[512]; - int iSocket = socket ( iDomain, SOCK_STREAM, 0 ); + int iSocket = (int) socket ( iDomain, SOCK_STREAM, 0 ); if ( iSocket<0 ) { @@ -2538,12 +2538,6 @@ char * ha_sphinx::UnpackString () } -static inline const char * FixNull ( const char * s ) -{ - return s ? s : "(null)"; -} - - bool ha_sphinx::UnpackSchema () { SPH_ENTER_METHOD(); @@ -2674,7 +2668,7 @@ bool ha_sphinx::UnpackStats ( CSphSEStats * pStats ) assert ( pStats ); char * pCurSave = m_pCur; - for ( uint i=0; istore ( sBuf, pCur-sBuf, &my_charset_bin ); + af->store ( sBuf, uint(pCur-sBuf), &my_charset_bin ); } break; @@ -3386,39 +3380,39 @@ ha_rows ha_sphinx::records_in_range ( uint, key_range *, key_range * ) // currently provided for doing that. // // Called from handle.cc by ha_create_table(). -int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) +int ha_sphinx::create ( const char * name, TABLE * table_arg, HA_CREATE_INFO * ) { SPH_ENTER_METHOD(); char sError[256]; CSphSEShare tInfo; - if ( !ParseUrl ( &tInfo, table, true ) ) + if ( !ParseUrl ( &tInfo, table_arg, true ) ) SPH_RET(-1); // check SphinxAPI table for ( ; !tInfo.m_bSphinxQL; ) { // check system fields (count and types) - if ( table->s->fieldss->fieldsfield[0] ) ) + if ( !IsIDField ( table_arg->field[0] ) ) { my_snprintf ( sError, sizeof(sError), "%s: 1st column (docid) MUST be unsigned integer or bigint", name ); break; } - if ( !IsIntegerFieldType ( table->field[1]->type() ) ) + if ( !IsIntegerFieldType ( table_arg->field[1]->type() ) ) { my_snprintf ( sError, sizeof(sError), "%s: 2nd column (weight) MUST be integer or bigint", name ); break; } - enum_field_types f2 = table->field[2]->type(); + enum_field_types f2 = table_arg->field[2]->type(); if ( f2!=MYSQL_TYPE_VARCHAR && f2!=MYSQL_TYPE_BLOB && f2!=MYSQL_TYPE_MEDIUM_BLOB && f2!=MYSQL_TYPE_LONG_BLOB && f2!=MYSQL_TYPE_TINY_BLOB ) { @@ -3428,28 +3422,28 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) // check attributes int i; - for ( i=3; i<(int)table->s->fields; i++ ) + for ( i=3; i<(int)table_arg->s->fields; i++ ) { - enum_field_types eType = table->field[i]->type(); + enum_field_types eType = table_arg->field[i]->type(); if ( eType!=MYSQL_TYPE_TIMESTAMP && !IsIntegerFieldType(eType) && eType!=MYSQL_TYPE_VARCHAR && eType!=MYSQL_TYPE_FLOAT ) { my_snprintf ( sError, sizeof(sError), "%s: %dth column (attribute %s) MUST be integer, bigint, timestamp, varchar, or float", - name, i+1, table->field[i]->field_name ); + name, i+1, table_arg->field[i]->field_name ); break; } } - if ( i!=(int)table->s->fields ) + if ( i!=(int)table_arg->s->fields ) break; // check index if ( - table->s->keys!=1 || - table->key_info[0].user_defined_key_parts!=1 || - strcasecmp ( table->key_info[0].key_part[0].field->field_name, table->field[2]->field_name ) ) + table_arg->s->keys!=1 || + table_arg->key_info[0].user_defined_key_parts!=1 || + strcasecmp ( table_arg->key_info[0].key_part[0].field->field_name, table->field[2]->field_name ) ) { my_snprintf ( sError, sizeof(sError), "%s: there must be an index on '%s' column", - name, table->field[2]->field_name ); + name, table_arg->field[2]->field_name ); break; } @@ -3464,13 +3458,13 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) sError[0] = '\0'; // check that 1st column is id, is of int type, and has an index - if ( strcmp ( table->field[0]->field_name, "id" ) ) + if ( strcmp ( table_arg->field[0]->field_name, "id" ) ) { my_snprintf ( sError, sizeof(sError), "%s: 1st column must be called 'id'", name ); break; } - if ( !IsIDField ( table->field[0] ) ) + if ( !IsIDField ( table_arg->field[0] ) ) { my_snprintf ( sError, sizeof(sError), "%s: 'id' column must be INT UNSIGNED or BIGINT", name ); break; @@ -3478,22 +3472,22 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) // check index if ( - table->s->keys!=1 || - table->key_info[0].user_defined_key_parts!=1 || - strcasecmp ( table->key_info[0].key_part[0].field->field_name, "id" ) ) + table_arg->s->keys!=1 || + table_arg->key_info[0].user_defined_key_parts!=1 || + strcasecmp ( table_arg->key_info[0].key_part[0].field->field_name, "id" ) ) { my_snprintf ( sError, sizeof(sError), "%s: 'id' column must be indexed", name ); break; } // check column types - for ( int i=1; i<(int)table->s->fields; i++ ) + for ( int i=1; i<(int)table_arg->s->fields; i++ ) { - enum_field_types eType = table->field[i]->type(); + enum_field_types eType = table_arg->field[i]->type(); if ( eType!=MYSQL_TYPE_TIMESTAMP && !IsIntegerFieldType(eType) && eType!=MYSQL_TYPE_VARCHAR && eType!=MYSQL_TYPE_FLOAT ) { my_snprintf ( sError, sizeof(sError), "%s: column %d(%s) is of unsupported type (use int/bigint/timestamp/varchar/float)", - name, i+1, table->field[i]->field_name ); + name, i+1, table_arg->field[i]->field_name ); break; } } @@ -3507,8 +3501,11 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * ) // report and bail if ( sError[0] ) { - my_error ( ER_CANT_CREATE_TABLE, MYF(0), - table->s->db.str, table->s->table_name, sError ); + my_printf_error(ER_CANT_CREATE_TABLE, + "Can\'t create table %s.%s (Error: %s)", + MYF(0), + table_arg->s->db.str, + table_arg->s->table_name.str, sError); SPH_RET(-1); } diff --git a/storage/sphinx/snippets_udf.cc b/storage/sphinx/snippets_udf.cc index 2a290bd8de943394db0a55a2d123f56ea67e6a38..ea8246c46f3e1c4813d70233f18bde8fb16a05bc 100644 --- a/storage/sphinx/snippets_udf.cc +++ b/storage/sphinx/snippets_udf.cc @@ -178,10 +178,10 @@ enum SEARCHD_WARNING = 3 ///< general success, warning message and command-specific reply follow }; -#define SPHINXSE_DEFAULT_SCHEME "sphinx" -#define SPHINXSE_DEFAULT_HOST "127.0.0.1" +#define SPHINXSE_DEFAULT_SCHEME (char*) "sphinx" +#define SPHINXSE_DEFAULT_HOST (char*) "127.0.0.1" #define SPHINXSE_DEFAULT_PORT 9312 -#define SPHINXSE_DEFAULT_INDEX "*" +#define SPHINXSE_DEFAULT_INDEX (char*) "*" class CSphBuffer { @@ -447,7 +447,7 @@ int CSphUrl::Connect() uint uServerVersion; uint uClientVersion = htonl ( SPHINX_SEARCHD_PROTO ); int iSocket = -1; - char * pError = NULL; + const char * pError = NULL; do { iSocket = socket ( iDomain, SOCK_STREAM, 0 ); diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 7d2924ce87288c648fbf242428ead65b9d2fc807..c559f562e98ade2cb11e702505f486da1e9dffd6 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -712,7 +712,7 @@ int ha_spider::close() } } - if (!thd || !*thd_ha_data(thd, spider_hton_ptr)) + if (!thd || !thd_get_ha_data(thd, spider_hton_ptr)) { for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) conns[roop_count] = NULL; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index fc3d9ecc25f83d7f6d8abb3f1474d996b1beee4c..5de41ac0f98749d01986f3b0976403391ac3c4fe 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -69,9 +69,6 @@ extern PSI_thread_key spd_key_thd_bg_crd; extern PSI_thread_key spd_key_thd_bg_mon; #endif #endif - -extern pthread_mutex_t spider_global_trx_mutex; -extern SPIDER_TRX *spider_global_trx; #endif HASH spider_open_connections; @@ -2807,9 +2804,6 @@ void *spider_bg_sts_action( DBUG_RETURN(NULL); } share->bg_sts_thd = thd; -/* - spider.trx = spider_global_trx; -*/ spider.trx = trx; spider.share = share; spider.conns = conns; @@ -2922,13 +2916,11 @@ void *spider_bg_sts_action( { if (!conns[spider.search_link_idx]) { - pthread_mutex_lock(&spider_global_trx_mutex); spider_get_conn(share, spider.search_link_idx, share->conn_keys[spider.search_link_idx], - spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, + trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num); conns[spider.search_link_idx]->error_mode = 0; - pthread_mutex_unlock(&spider_global_trx_mutex); /* if ( error_num && @@ -2937,7 +2929,7 @@ void *spider_bg_sts_action( ) { lex_start(thd); error_num = spider_ping_table_mon_from_table( - spider_global_trx, + trx, thd, share, (uint32) share->monitoring_sid[spider.search_link_idx], @@ -2958,7 +2950,6 @@ void *spider_bg_sts_action( } if (spider.search_link_idx != -1 && conns[spider.search_link_idx]) { - DBUG_ASSERT(!conns[spider.search_link_idx]->thd); #ifdef WITH_PARTITION_STORAGE_ENGINE if (spider_get_sts(share, spider.search_link_idx, share->bg_sts_try_time, &spider, @@ -2979,7 +2970,7 @@ void *spider_bg_sts_action( ) { lex_start(thd); error_num = spider_ping_table_mon_from_table( - spider_global_trx, + trx, thd, share, (uint32) share->monitoring_sid[spider.search_link_idx], @@ -3192,9 +3183,6 @@ void *spider_bg_crd_action( table.s = share->table_share; table.field = share->table_share->field; table.key_info = share->table_share->key_info; -/* - spider.trx = spider_global_trx; -*/ spider.trx = trx; spider.change_table_ptr(&table, share->table_share); spider.share = share; @@ -3308,13 +3296,11 @@ void *spider_bg_crd_action( { if (!conns[spider.search_link_idx]) { - pthread_mutex_lock(&spider_global_trx_mutex); spider_get_conn(share, spider.search_link_idx, share->conn_keys[spider.search_link_idx], - spider_global_trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, + trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num); conns[spider.search_link_idx]->error_mode = 0; - pthread_mutex_unlock(&spider_global_trx_mutex); /* if ( error_num && @@ -3323,7 +3309,7 @@ void *spider_bg_crd_action( ) { lex_start(thd); error_num = spider_ping_table_mon_from_table( - spider_global_trx, + trx, thd, share, (uint32) share->monitoring_sid[spider.search_link_idx], @@ -3344,7 +3330,6 @@ void *spider_bg_crd_action( } if (spider.search_link_idx != -1 && conns[spider.search_link_idx]) { - DBUG_ASSERT(!conns[spider.search_link_idx]->thd); #ifdef WITH_PARTITION_STORAGE_ENGINE if (spider_get_crd(share, spider.search_link_idx, share->bg_crd_try_time, &spider, &table, @@ -3365,7 +3350,7 @@ void *spider_bg_crd_action( ) { lex_start(thd); error_num = spider_ping_table_mon_from_table( - spider_global_trx, + trx, thd, share, (uint32) share->monitoring_sid[spider.search_link_idx], @@ -3717,7 +3702,7 @@ void *spider_bg_mon_action( { lex_start(thd); error_num = spider_ping_table_mon_from_table( - spider_global_trx, + trx, thd, share, (uint32) share->monitoring_sid[link_idx], diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index c3dfe8b8cf24373d54bb67d74e04540ddc04ce9b..8d7b912657066037a21ec9c46499f294520c750c 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -29,6 +29,10 @@ #endif #ifdef HAVE_ORACLE_OCI +#if (defined(WIN32) || defined(_WIN32) || defined(WINDOWS) || defined(_WINDOWS)) +#include +#define strcasestr StrStr +#endif #include #include "spd_err.h" #include "spd_param.h" @@ -3817,7 +3821,7 @@ int spider_db_oracle_util::open_item_func( { Item_func_conv_charset *item_func_conv_charset = (Item_func_conv_charset *)item_func; - CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset; + CHARSET_INFO *conv_charset = item_func_conv_charset->collation.collation; uint cset_length = strlen(conv_charset->csname); if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 8f892869679b49173a7e8decb5d3e98f9aa639b5..5c3ef9cabdfa103c2a0c26f6be851f60a29352ac 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -371,6 +371,14 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( if (direct_sql->access_mode == 0) { #endif + if (direct_sql->dbton_id == SPIDER_DBTON_SIZE) + { + /* Invalid target wrapper */ + *error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; + my_printf_error(*error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, + MYF(0), direct_sql->tgt_wrapper); + goto error_alloc_conn; + } if (!(conn = (SPIDER_CONN *) spider_bulk_malloc(spider_current_trx, 32, MYF(MY_WME | MY_ZEROFILL), &conn, sizeof(*conn), @@ -398,6 +406,14 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->default_database.init_calc_mem(138); #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) } else { + if (direct_sql->dbton_id == SPIDER_DBTON_SIZE) + { + /* Invalid target wrapper */ + *error_num = ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM; + my_printf_error(*error_num, ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, + MYF(0), direct_sql->tgt_wrapper); + goto error_alloc_conn; + } if (!(conn = (SPIDER_CONN *) spider_bulk_malloc(spider_current_trx, 33, MYF(MY_WME | MY_ZEROFILL), &conn, sizeof(*conn), diff --git a/storage/spider/spd_malloc.h b/storage/spider/spd_malloc.h index 3c5c6e67c2a461646ce7c8b512610d01fc0ee8d5..697595edeb639a0d342b0880e7b4bbe5559da717 100644 --- a/storage/spider/spd_malloc.h +++ b/storage/spider/spd_malloc.h @@ -19,7 +19,7 @@ #define spider_bulk_malloc(A,B,C,...) \ spider_bulk_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,__VA_ARGS__) #define spider_current_trx \ - (current_thd ? ((SPIDER_TRX *) *thd_ha_data(current_thd, spider_hton_ptr)) : NULL) + (current_thd ? ((SPIDER_TRX *) thd_get_ha_data(current_thd, spider_hton_ptr)) : NULL) #define init_calc_mem(A) init_mem_calc(A,__func__,__FILE__,__LINE__) diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 77a2969d0610a428545b5fdd6b640941a1283d83..6f04e08dc93846a61a2594f674c72d826de1f332 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -52,11 +52,6 @@ extern PSI_mutex_key spd_key_mutex_mon_list_update_status; extern PSI_mutex_key spd_key_mutex_mon_table_cache; #endif -#ifndef WITHOUT_SPIDER_BG_SEARCH -extern pthread_mutex_t spider_global_trx_mutex; -extern SPIDER_TRX *spider_global_trx; -#endif - HASH *spider_udf_table_mon_list_hash; uint spider_udf_table_mon_list_hash_id; const char *spider_udf_table_mon_list_hash_func_name; @@ -130,7 +125,6 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( ) #endif { - DBUG_ASSERT(trx != spider_global_trx); if ( table_mon_list && table_mon_list->mon_table_cache_version != mon_table_cache_version @@ -608,29 +602,17 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn( ) { SPIDER_CONN *conn; DBUG_ENTER("spider_get_ping_table_tgt_conn"); -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (trx == spider_global_trx) - pthread_mutex_lock(&spider_global_trx_mutex); -#endif if ( !(conn = spider_get_conn( share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, error_num)) ) { -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (trx == spider_global_trx) - pthread_mutex_unlock(&spider_global_trx_mutex); -#endif my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); *error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; goto error; } #ifndef DBUG_OFF - if (trx == spider_global_trx) - { - DBUG_ASSERT(!conn->thd); - } DBUG_PRINT("info",("spider conn->thd=%p", conn->thd)); if (conn->thd) { @@ -638,10 +620,6 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn( } #endif conn->error_mode = 0; -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (trx == spider_global_trx) - pthread_mutex_unlock(&spider_global_trx_mutex); -#endif DBUG_RETURN(conn); error: diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 94d9f2257e1c45457496fce4d78b4d34718179fc..130edc5ee8a2b657436a0f5f41d0d2b10f091b9f 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -41,6 +41,27 @@ #include "spd_direct_sql.h" #include "spd_malloc.h" +inline MYSQL_THD spider_create_thd() +{ + THD *thd; + my_thread_init(); + if (!(thd = new THD())) + my_thread_end(); + else + { +#ifdef HAVE_PSI_INTERFACE + mysql_thread_set_psi_id(thd->thread_id); +#endif + thd->thread_stack = (char *) &thd; + thd->store_globals(); + } + return thd; +} +inline void spider_destroy_thd(MYSQL_THD thd) +{ + delete thd; +} + ulong *spd_db_att_thread_id; #ifdef SPIDER_XID_USES_xid_cache_iterate #else @@ -77,9 +98,6 @@ PSI_mutex_key spd_key_mutex_conn; PSI_mutex_key spd_key_mutex_hs_r_conn; PSI_mutex_key spd_key_mutex_hs_w_conn; #endif -#ifndef WITHOUT_SPIDER_BG_SEARCH -PSI_mutex_key spd_key_mutex_global_trx; -#endif PSI_mutex_key spd_key_mutex_open_conn; PSI_mutex_key spd_key_mutex_allocated_thds; PSI_mutex_key spd_key_mutex_mon_table_cache; @@ -123,9 +141,6 @@ static PSI_mutex_info all_spider_mutexes[]= #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) { &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL}, { &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL}, -#endif -#ifndef WITHOUT_SPIDER_BG_SEARCH - { &spd_key_mutex_global_trx, "global_trx", PSI_FLAG_GLOBAL}, #endif { &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL}, { &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL}, @@ -280,9 +295,6 @@ pthread_mutex_t spider_allocated_thds_mutex; #ifndef WITHOUT_SPIDER_BG_SEARCH pthread_attr_t spider_pt_attr; - -pthread_mutex_t spider_global_trx_mutex; -SPIDER_TRX *spider_global_trx; #endif extern pthread_mutex_t spider_mem_calc_mutex; @@ -5994,7 +6006,7 @@ int spider_close_connection( SPIDER_CONN *conn; SPIDER_TRX *trx; DBUG_ENTER("spider_close_connection"); - if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ trx->tmp_spider->conns = &conn; @@ -6049,6 +6061,7 @@ int spider_db_done( void *p ) { int roop_count; + bool do_delete_thd; THD *thd = current_thd, *tmp_thd; SPIDER_CONN *conn; SPIDER_INIT_ERROR_TABLE *spider_init_error_table; @@ -6056,9 +6069,17 @@ int spider_db_done( SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share; DBUG_ENTER("spider_db_done"); -#ifndef WITHOUT_SPIDER_BG_SEARCH - spider_free_trx(spider_global_trx, TRUE); -#endif + /* Begin Spider plugin deinit */ + if (thd) + do_delete_thd = FALSE; + else + { + /* Create a thread for Spider plugin deinit */ + thd = spider_create_thd(); + if (!thd) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + do_delete_thd = TRUE; + } for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--) { @@ -6098,21 +6119,22 @@ int spider_db_done( pthread_mutex_destroy(&spider_udf_table_mon_mutexes[roop_count]); spider_free(NULL, spider_udf_table_mon_mutexes, MYF(0)); - if (thd && thd_sql_command(thd) == SQLCOM_UNINSTALL_PLUGIN) { - pthread_mutex_lock(&spider_allocated_thds_mutex); - while ((tmp_thd = (THD *) my_hash_element(&spider_allocated_thds, 0))) + pthread_mutex_lock(&spider_allocated_thds_mutex); + while ((tmp_thd = (THD *) my_hash_element(&spider_allocated_thds, 0))) + { + SPIDER_TRX *trx = (SPIDER_TRX *) + thd_get_ha_data(tmp_thd, spider_hton_ptr); + if (trx) { - SPIDER_TRX *trx = (SPIDER_TRX *) *thd_ha_data(tmp_thd, spider_hton_ptr); - if (trx) - { - DBUG_ASSERT(tmp_thd == trx->thd); - spider_free_trx(trx, FALSE); - *thd_ha_data(tmp_thd, spider_hton_ptr) = (void *) NULL; - } else - my_hash_delete(&spider_allocated_thds, (uchar *) tmp_thd); + DBUG_ASSERT(tmp_thd == trx->thd); + spider_free_trx(trx, FALSE); + thd_set_ha_data(tmp_thd, spider_hton_ptr, NULL); } - pthread_mutex_unlock(&spider_allocated_thds_mutex); + else + my_hash_delete(&spider_allocated_thds, (uchar *) tmp_thd); } + pthread_mutex_unlock(&spider_allocated_thds_mutex); + #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) pthread_mutex_lock(&spider_hs_w_conn_mutex); while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_w_conn_hash, 0))) @@ -6226,9 +6248,6 @@ int spider_db_done( pthread_mutex_destroy(&spider_mon_table_cache_mutex); pthread_mutex_destroy(&spider_allocated_thds_mutex); pthread_mutex_destroy(&spider_open_conn_mutex); -#ifndef WITHOUT_SPIDER_BG_SEARCH - pthread_mutex_destroy(&spider_global_trx_mutex); -#endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) pthread_mutex_destroy(&spider_hs_w_conn_mutex); pthread_mutex_destroy(&spider_hs_r_conn_mutex); @@ -6261,6 +6280,11 @@ int spider_db_done( spider_current_alloc_mem[roop_count] ? "NG" : "OK" )); } + + /* End Spider plugin deinit */ + if (do_delete_thd) + spider_destroy_thd(thd); + /* DBUG_ASSERT(0); */ @@ -6470,18 +6494,6 @@ int spider_db_init( error_num = HA_ERR_OUT_OF_MEM; goto error_conn_mutex_init; } -#ifndef WITHOUT_SPIDER_BG_SEARCH -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_global_trx_mutex, MY_MUTEX_INIT_FAST)) -#else - if (mysql_mutex_init(spd_key_mutex_global_trx, - &spider_global_trx_mutex, MY_MUTEX_INIT_FAST)) -#endif - { - error_num = HA_ERR_OUT_OF_MEM; - goto error_global_trx_mutex_init; - } -#endif #if MYSQL_VERSION_ID < 50500 if (pthread_mutex_init(&spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) #else @@ -6746,16 +6758,9 @@ int spider_db_init( } } -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (!(spider_global_trx = spider_get_trx(NULL, FALSE, &error_num))) - goto error; -#endif - DBUG_RETURN(0); #ifndef WITHOUT_SPIDER_BG_SEARCH -error: - roop_count = SPIDER_DBTON_SIZE; error_init_dbton: for (roop_count--; roop_count >= 0; roop_count--) { @@ -6857,10 +6862,6 @@ int spider_db_init( #endif pthread_mutex_destroy(&spider_open_conn_mutex); error_open_conn_mutex_init: -#ifndef WITHOUT_SPIDER_BG_SEARCH - pthread_mutex_destroy(&spider_global_trx_mutex); -error_global_trx_mutex_init: -#endif pthread_mutex_destroy(&spider_conn_mutex); error_conn_mutex_init: pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 26c9662e08410a336e074e2b0661778e666876f2..f6bf39b813e9d215bf3b62b86b547daf39482b25 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1147,7 +1147,7 @@ SPIDER_TRX *spider_get_trx( if ( !thd || - !(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr)) + !(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr)) ) { DBUG_PRINT("info",("spider create new trx")); if (!(trx = (SPIDER_TRX *) @@ -1185,7 +1185,7 @@ SPIDER_TRX *spider_get_trx( goto error_init_hash; spider_alloc_calc_mem_init(trx->trx_conn_hash, 151); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_conn_hash, trx->trx_conn_hash.array.max_element * trx->trx_conn_hash.array.size_of_element); @@ -1197,7 +1197,7 @@ SPIDER_TRX *spider_get_trx( goto error_init_another_hash; spider_alloc_calc_mem_init(trx->trx_another_conn_hash, 152); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_another_conn_hash, trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); @@ -1210,7 +1210,7 @@ SPIDER_TRX *spider_get_trx( goto error_hs_r_init_hash; spider_alloc_calc_mem_init(trx->trx_hs_r_conn_hash, 153); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_hs_r_conn_hash, trx->trx_hs_r_conn_hash.array.max_element * trx->trx_hs_r_conn_hash.array.size_of_element); @@ -1222,7 +1222,7 @@ SPIDER_TRX *spider_get_trx( goto error_hs_w_init_hash; spider_alloc_calc_mem_init(trx->trx_hs_w_conn_hash, 154); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_hs_w_conn_hash, trx->trx_hs_w_conn_hash.array.max_element * trx->trx_hs_w_conn_hash.array.size_of_element); @@ -1236,7 +1236,7 @@ SPIDER_TRX *spider_get_trx( goto error_direct_hs_r_init_hash; spider_alloc_calc_mem_init(trx->trx_direct_hs_r_conn_hash, 155); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_direct_hs_r_conn_hash, trx->trx_direct_hs_r_conn_hash.array.max_element * trx->trx_direct_hs_r_conn_hash.array.size_of_element); @@ -1248,7 +1248,7 @@ SPIDER_TRX *spider_get_trx( goto error_direct_hs_w_init_hash; spider_alloc_calc_mem_init(trx->trx_direct_hs_w_conn_hash, 156); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_direct_hs_w_conn_hash, trx->trx_direct_hs_w_conn_hash.array.max_element * trx->trx_direct_hs_w_conn_hash.array.size_of_element); @@ -1261,7 +1261,7 @@ SPIDER_TRX *spider_get_trx( goto error_init_alter_hash; spider_alloc_calc_mem_init(trx->trx_alter_table_hash, 157); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_alter_table_hash, trx->trx_alter_table_hash.array.max_element * trx->trx_alter_table_hash.array.size_of_element); @@ -1273,7 +1273,7 @@ SPIDER_TRX *spider_get_trx( goto error_init_trx_ha_hash; spider_alloc_calc_mem_init(trx->trx_ha_hash, 158); spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_ha_hash, trx->trx_ha_hash.array.max_element * trx->trx_ha_hash.array.size_of_element); @@ -1395,7 +1395,7 @@ SPIDER_TRX *spider_get_trx( pthread_mutex_unlock(&spider_allocated_thds_mutex); trx->registed_allocated_thds = TRUE; } - *thd_ha_data(thd, spider_hton_ptr) = (void *) trx; + thd_set_ha_data(thd, spider_hton_ptr, trx); } } @@ -1441,7 +1441,7 @@ SPIDER_TRX *spider_get_trx( my_hash_free(&trx->trx_ha_hash); error_init_trx_ha_hash: spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_alter_table_hash_id, trx->trx_alter_table_hash.array.max_element * trx->trx_alter_table_hash.array.size_of_element); @@ -1449,14 +1449,14 @@ SPIDER_TRX *spider_get_trx( error_init_alter_hash: #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_direct_hs_w_conn_hash_id, trx->trx_direct_hs_w_conn_hash.array.max_element * trx->trx_direct_hs_w_conn_hash.array.size_of_element); my_hash_free(&trx->trx_direct_hs_w_conn_hash); error_direct_hs_w_init_hash: spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_direct_hs_r_conn_hash_id, trx->trx_direct_hs_r_conn_hash.array.max_element * trx->trx_direct_hs_r_conn_hash.array.size_of_element); @@ -1465,14 +1465,14 @@ SPIDER_TRX *spider_get_trx( #endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_hs_w_conn_hash_id, trx->trx_hs_w_conn_hash.array.max_element * trx->trx_hs_w_conn_hash.array.size_of_element); my_hash_free(&trx->trx_hs_w_conn_hash); error_hs_w_init_hash: spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_hs_r_conn_hash_id, trx->trx_hs_r_conn_hash.array.max_element * trx->trx_hs_r_conn_hash.array.size_of_element); @@ -1480,14 +1480,14 @@ SPIDER_TRX *spider_get_trx( error_hs_r_init_hash: #endif spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_another_conn_hash_id, trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); my_hash_free(&trx->trx_another_conn_hash); error_init_another_hash: spider_free_mem_calc( - thd ? ((SPIDER_TRX *) *thd_ha_data(thd, spider_hton_ptr)) : NULL, + thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_conn_hash_id, trx->trx_conn_hash.array.max_element * trx->trx_conn_hash.array.size_of_element); @@ -1526,7 +1526,7 @@ int spider_free_trx( if (need_lock) pthread_mutex_unlock(&spider_allocated_thds_mutex); } - *thd_ha_data(trx->thd, spider_hton_ptr) = (void *) NULL; + thd_set_ha_data(trx->thd, spider_hton_ptr, NULL); } spider_free_trx_alloc(trx); spider_merge_mem_calc(trx, TRUE); @@ -3298,7 +3298,7 @@ int spider_commit( SPIDER_CONN *conn; DBUG_ENTER("spider_commit"); - if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ #ifdef HA_CAN_BULK_ACCESS @@ -3388,7 +3388,7 @@ int spider_rollback( SPIDER_CONN *conn; DBUG_ENTER("spider_rollback"); - if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ #ifdef HA_CAN_BULK_ACCESS @@ -3463,7 +3463,7 @@ int spider_xa_prepare( if (all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { - if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr))) + if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ DBUG_PRINT("info",("spider trx_start=%s", diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 7ea987280340cdefab2460de8da6755bea79b84d..e90e0b0ec679ad49aa9046bbb8cf9c4a166ba2f9 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -1,9 +1,12 @@ -SET(TOKUDB_VERSION 5.6.38-83.0) +SET(TOKUDB_VERSION 5.6.39-83.1) # PerconaFT only supports x86-64 and cmake-2.8.9+ IF(CMAKE_VERSION VERSION_LESS "2.8.9") MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB") ELSEIF(NOT HAVE_DLOPEN) MESSAGE(STATUS "dlopen is required by TokuDB") +ELSEIF(PLUGIN_PERFSCHEMA MATCHES "^NO$") + MESSAGE(STATUS "Performance Schema is required by TokuDB") + RETURN() ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # tokudb requires F_NOCACHE or O_DIRECT, and designated initializers @@ -41,6 +44,7 @@ IF(NOT LIBJEMALLOC) MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported") ENDIF() +MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough") diff --git a/storage/tokudb/PerconaFT/.clang-format b/storage/tokudb/PerconaFT/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..0888185848d12fc0ed6c251f1347081e90d09157 --- /dev/null +++ b/storage/tokudb/PerconaFT/.clang-format @@ -0,0 +1,36 @@ +Language: Cpp +BasedOnStyle: Google + +# The following parameters are default for Google style, +# but as they are important for our project they +# are set explicitly here +AlignAfterOpenBracket: Align +BreakBeforeBinaryOperators: None +ColumnLimit: 80 +PointerAlignment: Left +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +UseTab: Never + +# Non-default parametes +NamespaceIndentation: All +IndentWidth: 4 +TabWidth: 4 +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +BinPackParameters: false +BinPackArguments: false +ExperimentalAutoDetectBinPacking: false +AllowAllParametersOfDeclarationOnNextLine: false +#AlignConsecutiveAssignments: yes +#AlignConsecutiveDeclarations: yes +BreakStringLiterals: false +ReflowComments: true diff --git a/storage/tokudb/PerconaFT/CMakeLists.txt b/storage/tokudb/PerconaFT/CMakeLists.txt index 3973ec71b528ceada35f08b84fccacf6ed950015..3b6b909f6357a1b3d4407be4ba95f4a713246ddf 100644 --- a/storage/tokudb/PerconaFT/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/CMakeLists.txt @@ -9,6 +9,12 @@ project(TokuDB) set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") +# See: https://jira.percona.com/browse/TDB-93 +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member") +ENDIF() + # detect when we are being built as a subproject if (DEFINED MYSQL_PROJECT_NAME_DOCSTRING) add_definitions( -DMYSQL_TOKUDB_ENGINE=1) diff --git a/storage/tokudb/PerconaFT/README.md b/storage/tokudb/PerconaFT/README.md index d53caf001901285562ac1ff964ee4fe0b83cb258..ffb646b67afdaa40cf81c251c599579dd05fda22 100644 --- a/storage/tokudb/PerconaFT/README.md +++ b/storage/tokudb/PerconaFT/README.md @@ -9,20 +9,18 @@ PerconaFT is provided as a shared library with an interface similar to Berkeley DB. To build the full MySQL product, see the instructions for -[Percona/tokudb-engine][tokudb-engine]. To build TokuMX, see the instructions -for [Percona/percona-server-mongodb][mongo]. This document covers PerconaFT only. +[Percona/percona-server][percona-server]. This document covers PerconaFT only. -[tokudb-engine]: https://github.com/Percona/tokudb-engine -[mongo]: https://github.com/Percona/percona-server-mongodb +[percona-server]: https://github.com/Percona/percona-server Building -------- PerconaFT is built using CMake >= 2.8.9. Out-of-source builds are -recommended. You need a C++11 compiler, though only GCC >= 4.7 and -Apple's Clang are tested. You also need zlib development packages -(`yum install zlib-devel` or `apt-get install zlib1g-dev`). +recommended. You need a C++11 compiler, though only some versions +of GCC >= 4.7 and Clang are tested. You also need zlib development +packages (`yum install zlib-devel` or `apt-get install zlib1g-dev`). You will also need the source code for jemalloc, checked out in `third_party/`. @@ -42,16 +40,16 @@ CC=gcc47 CXX=g++47 cmake \ cmake --build . --target install ``` -This will build `libtokudb.so` and `libtokuportability.so` and install it, +This will build `libft.so` and `libtokuportability.so` and install it, some header files, and some examples to `percona-ft/prefix/`. It will also build jemalloc and install it alongside these libraries, you should link to that if you are planning to run benchmarks or in production. ### Platforms -PerconaFT is supported on 64-bit Centos, should work on other 64-bit linux -distributions, and may work on OSX 10.8 and FreeBSD. PerconaFT is not -supported on 32-bit systems. +PerconaFT is supported on 64-bit Centos, Debian, and Ubuntu and should work +on other 64-bit linux distributions, and may work on OSX 10.8 and FreeBSD. +PerconaFT is not supported on 32-bit systems. [Transparent hugepages][transparent-hugepages] is a feature in newer linux kernel versions that causes problems for the memory usage tracking @@ -97,16 +95,9 @@ We have two publicly accessible mailing lists for TokuDB: - tokudb-dev@googlegroups.com is for discussion of the development of TokuDB. -and two for TokuMX: - - - tokumx-user@googlegroups.com is for general and support related - questions about the use of TokuMX. - - tokumx-dev@googlegroups.com is for discussion of the development of - TokuMX. - All source code and test contributions must be provided under a [BSD 2-Clause][bsd-2] license. For any small change set, the license text may be contained within the commit comment and the pull request. For larger contributions, the license must be presented in a COPYING. file in the root of the PerconaFT project. Please see the [BSD 2-Clause license template][bsd-2] for the content of the license text. -[jira]: https://tokutek.atlassian.net/browse/FT/ +[jira]: https://jira.percona.com/projects/TDB [bsd-2]: http://opensource.org/licenses/BSD-2-Clause/ diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake index 385723aebc7b0a7048e4733363d91cf7025ae9aa..50d35ee4906ee3ffcd09e6ecaeee20304963e931 100644 --- a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake +++ b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake @@ -149,7 +149,7 @@ set_cflags_if_supported( -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith - -Wshadow + #-Wshadow will fail with GCC-8 ${OPTIONAL_CFLAGS} ## other flags to try: #-Wunsafe-loop-optimizations diff --git a/storage/tokudb/PerconaFT/ft/ft-ops.cc b/storage/tokudb/PerconaFT/ft/ft-ops.cc index 60885ed9f33b153934ab38ac348435a6b611a06b..eb8696423cac1ac32808b336063fca57f800955f 100644 --- a/storage/tokudb/PerconaFT/ft/ft-ops.cc +++ b/storage/tokudb/PerconaFT/ft/ft-ops.cc @@ -821,22 +821,22 @@ int toku_ftnode_fetch_callback(CACHEFILE UU(cachefile), fprintf( stderr, "%s:%d:toku_ftnode_fetch_callback - " - "file[%s], blocknum[%ld], toku_deserialize_ftnode_from " + "file[%s], blocknum[%lld], toku_deserialize_ftnode_from " "failed with a checksum error.\n", __FILE__, __LINE__, toku_cachefile_fname_in_env(cachefile), - blocknum.b); + (longlong)blocknum.b); } else { fprintf( stderr, "%s:%d:toku_ftnode_fetch_callback - " - "file[%s], blocknum[%ld], toku_deserialize_ftnode_from " + "file[%s], blocknum[%lld], toku_deserialize_ftnode_from " "failed with %d.\n", __FILE__, __LINE__, toku_cachefile_fname_in_env(cachefile), - blocknum.b, + (longlong)blocknum.b, r); } // make absolutely sure we crash before doing anything else. @@ -4880,6 +4880,94 @@ static void toku_pfs_keys_init(const char *toku_instr_group_name) { toku_instr_probe_1 = new toku_instr_probe(*fti_probe_1_key); } +static void toku_pfs_keys_destroy(void) { + delete kibbutz_mutex_key; + delete minicron_p_mutex_key; + delete queue_result_mutex_key; + delete tpool_lock_mutex_key; + delete workset_lock_mutex_key; + delete bjm_jobs_lock_mutex_key; + delete log_internal_lock_mutex_key; + delete cachetable_ev_thread_lock_mutex_key; + delete cachetable_disk_nb_mutex_key; + delete safe_file_size_lock_mutex_key; + delete cachetable_m_mutex_key; + delete checkpoint_safe_mutex_key; + delete ft_ref_lock_mutex_key; + delete ft_open_close_lock_mutex_key; + delete loader_error_mutex_key; + delete bfs_mutex_key; + delete loader_bl_mutex_key; + delete loader_fi_lock_mutex_key; + delete loader_out_mutex_key; + delete result_output_condition_lock_mutex_key; + delete block_table_mutex_key; + delete rollback_log_node_cache_mutex_key; + delete txn_lock_mutex_key; + delete txn_state_lock_mutex_key; + delete txn_child_manager_mutex_key; + delete txn_manager_lock_mutex_key; + delete treenode_mutex_key; + delete locktree_request_info_mutex_key; + delete locktree_request_info_retry_mutex_key; + delete manager_mutex_key; + delete manager_escalation_mutex_key; + delete db_txn_struct_i_txn_mutex_key; + delete manager_escalator_mutex_key; + delete indexer_i_indexer_lock_mutex_key; + delete indexer_i_indexer_estimate_lock_mutex_key; + + delete tokudb_file_data_key; + delete tokudb_file_load_key; + delete tokudb_file_tmp_key; + delete tokudb_file_log_key; + + delete fti_probe_1_key; + + delete extractor_thread_key; + delete fractal_thread_key; + delete io_thread_key; + delete eviction_thread_key; + delete kibbutz_thread_key; + delete minicron_thread_key; + delete tp_internal_thread_key; + + delete result_state_cond_key; + delete bjm_jobs_wait_key; + delete cachetable_p_refcount_wait_key; + delete cachetable_m_flow_control_cond_key; + delete cachetable_m_ev_thread_cond_key; + delete bfs_cond_key; + delete result_output_condition_key; + delete manager_m_escalator_done_key; + delete lock_request_m_wait_cond_key; + delete queue_result_cond_key; + delete ws_worker_wait_key; + delete rwlock_wait_read_key; + delete rwlock_wait_write_key; + delete rwlock_cond_key; + delete tp_thread_wait_key; + delete tp_pool_wait_free_key; + delete frwlock_m_wait_read_key; + delete kibbutz_k_cond_key; + delete minicron_p_condvar_key; + delete locktree_request_info_retry_cv_key; + + delete multi_operation_lock_key; + delete low_priority_multi_operation_lock_key; + delete cachetable_m_list_lock_key; + delete cachetable_m_pending_lock_expensive_key; + delete cachetable_m_pending_lock_cheap_key; + delete cachetable_m_lock_key; + delete result_i_open_dbs_rwlock_key; + delete checkpoint_safe_rwlock_key; + delete cachetable_value_key; + delete safe_file_size_lock_rwlock_key; + + delete cachetable_disk_nb_rwlock_key; + delete toku_instr_probe_1; +} + int toku_ft_layer_init(void) { int r = 0; @@ -4916,8 +5004,7 @@ void toku_ft_layer_destroy(void) { toku_status_destroy(); partitioned_counters_destroy(); toku_scoped_malloc_destroy(); - - delete toku_instr_probe_1; + toku_pfs_keys_destroy(); // Portability must be cleaned up last toku_portability_destroy(); diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc index b24d72a5dff5b46e7eb5f27ea14cf39bed64891d..0d6573972d7c18adb98a1c20e5f859f37c15d43a 100644 --- a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc +++ b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc @@ -656,20 +656,20 @@ int deserialize_ft_from_fd_into_rbuf(int fd, fprintf(stderr, \ "%s:%d toku_deserialize_ft_from: " \ "filename[%s] " \ - "r[%d] max_acceptable_lsn[%lu]" \ - "r0[%d] checkpoint_lsn_0[%lu] checkpoint_count_0[%lu] " \ - "r1[%d] checkpoint_lsn_1[%lu] checkpoint_count_1[%lu]\n", \ + "r[%d] max_acceptable_lsn[%llu]" \ + "r0[%d] checkpoint_lsn_0[%llu] checkpoint_count_0[%llu] " \ + "r1[%d] checkpoint_lsn_1[%llu] checkpoint_count_1[%llu]\n", \ __FILE__, \ __LINE__, \ fn, \ r, \ - max_acceptable_lsn.lsn, \ + (ulonglong)max_acceptable_lsn.lsn, \ r0, \ - checkpoint_lsn_0.lsn, \ - checkpoint_count_0, \ + (ulonglong)checkpoint_lsn_0.lsn, \ + (ulonglong)checkpoint_count_0, \ r1, \ - checkpoint_lsn_1.lsn, \ - checkpoint_count_1); + (ulonglong)checkpoint_lsn_1.lsn, \ + (ulonglong)checkpoint_count_1); int toku_deserialize_ft_from(int fd, const char *fn, diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc index 55899905bafe239c0662a1182926b5f8825af79a..46bb8f81412c23f38dcbc7942cb5b5ea51d03b32 100644 --- a/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc +++ b/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc @@ -1170,11 +1170,11 @@ int verify_ftnode_sub_block(struct sub_block *sb, fprintf( stderr, "%s:%d:verify_ftnode_sub_block - " - "file[%s], blocknum[%ld], stored_xsum[%u] != actual_xsum[%u]\n", + "file[%s], blocknum[%lld], stored_xsum[%u] != actual_xsum[%u]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, stored_xsum, actual_xsum); dump_bad_block((Bytef *) sb->uncompressed_ptr, sb->uncompressed_size); @@ -1197,11 +1197,11 @@ static int deserialize_ftnode_info(struct sub_block *sb, FTNODE node) { fprintf( stderr, "%s:%d:deserialize_ftnode_info - " - "file[%s], blocknum[%ld], verify_ftnode_sub_block failed with %d\n", + "file[%s], blocknum[%lld], verify_ftnode_sub_block failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, r); dump_bad_block(static_cast(sb->uncompressed_ptr), sb->uncompressed_size); @@ -1253,11 +1253,11 @@ static int deserialize_ftnode_info(struct sub_block *sb, FTNODE node) { fprintf( stderr, "%s:%d:deserialize_ftnode_info - " - "file[%s], blocknum[%ld], data_size[%d] != rb.ndone[%d]\n", + "file[%s], blocknum[%lld], data_size[%d] != rb.ndone[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, data_size, rb.ndone); dump_bad_block(rb.buf, rb.size); @@ -1388,12 +1388,12 @@ static int deserialize_ftnode_partition( if (r != 0) { fprintf(stderr, "%s:%d:deserialize_ftnode_partition - " - "file[%s], blocknum[%ld], " + "file[%s], blocknum[%lld], " "verify_ftnode_sub_block failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, r); goto exit; } @@ -1410,12 +1410,12 @@ static int deserialize_ftnode_partition( if (ch != FTNODE_PARTITION_MSG_BUFFER) { fprintf(stderr, "%s:%d:deserialize_ftnode_partition - " - "file[%s], blocknum[%ld], ch[%d] != " + "file[%s], blocknum[%lld], ch[%d] != " "FTNODE_PARTITION_MSG_BUFFER[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, ch, FTNODE_PARTITION_MSG_BUFFER); dump_bad_block(rb.buf, rb.size); @@ -1433,12 +1433,12 @@ static int deserialize_ftnode_partition( if (ch != FTNODE_PARTITION_DMT_LEAVES) { fprintf(stderr, "%s:%d:deserialize_ftnode_partition - " - "file[%s], blocknum[%ld], ch[%d] != " + "file[%s], blocknum[%lld], ch[%d] != " "FTNODE_PARTITION_DMT_LEAVES[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, ch, FTNODE_PARTITION_DMT_LEAVES); dump_bad_block(rb.buf, rb.size); @@ -1457,11 +1457,11 @@ static int deserialize_ftnode_partition( if (rb.ndone != rb.size) { fprintf(stderr, "%s:%d:deserialize_ftnode_partition - " - "file[%s], blocknum[%ld], rb.ndone[%d] != rb.size[%d]\n", + "file[%s], blocknum[%lld], rb.ndone[%d] != rb.size[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, rb.ndone, rb.size); dump_bad_block(rb.buf, rb.size); @@ -1485,12 +1485,12 @@ static int decompress_and_deserialize_worker(struct rbuf curr_rbuf, const char *fname = toku_ftnode_get_cachefile_fname_in_env(node); fprintf(stderr, "%s:%d:decompress_and_deserialize_worker - " - "file[%s], blocknum[%ld], read_and_decompress_sub_block failed " + "file[%s], blocknum[%lld], read_and_decompress_sub_block failed " "with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, r); dump_bad_block(curr_rbuf.buf, curr_rbuf.size); goto exit; @@ -1502,12 +1502,12 @@ static int decompress_and_deserialize_worker(struct rbuf curr_rbuf, const char *fname = toku_ftnode_get_cachefile_fname_in_env(node); fprintf(stderr, "%s:%d:decompress_and_deserialize_worker - " - "file[%s], blocknum[%ld], deserialize_ftnode_partition failed " + "file[%s], blocknum[%lld], deserialize_ftnode_partition failed " "with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, r); dump_bad_block(curr_rbuf.buf, curr_rbuf.size); goto exit; @@ -1582,11 +1582,11 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], rb->size[%u] < 24\n", + "file[%s], blocknum[%lld], rb->size[%u] < 24\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, rb->size); dump_bad_block(rb->buf, rb->size); // TODO: What error do we return here? @@ -1602,12 +1602,12 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], unrecognized magic number " + "file[%s], blocknum[%lld], unrecognized magic number " "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, static_cast(magic)[0], static_cast(magic)[1], static_cast(magic)[2], @@ -1627,12 +1627,12 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], node->layout_version_read_from_disk[%d] " + "file[%s], blocknum[%lld], node->layout_version_read_from_disk[%d] " "< FT_FIRST_LAYOUT_VERSION_WITH_BASEMENT_NODES[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, node->layout_version_read_from_disk, FT_FIRST_LAYOUT_VERSION_WITH_BASEMENT_NODES); dump_bad_block(rb->buf, rb->size); @@ -1667,11 +1667,11 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], needed_size[%d] > rb->size[%d]\n", + "file[%s], blocknum[%lld], needed_size[%d] > rb->size[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, needed_size, rb->size); dump_bad_block(rb->buf, rb->size); @@ -1695,11 +1695,11 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], stored_checksum[%d] != checksum[%d]\n", + "file[%s], blocknum[%lld], stored_checksum[%d] != checksum[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, stored_checksum, checksum); dump_bad_block(rb->buf, rb->size); @@ -1717,12 +1717,12 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], rb->size[%d] - rb->ndone[%d] < " + "file[%s], blocknum[%lld], rb->size[%d] - rb->ndone[%d] < " "sb_node_info.compressed_size[%d] + 8\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, rb->size, rb->ndone, sb_node_info.compressed_size); @@ -1744,11 +1744,11 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], sb_node_info.xsum[%d] != actual_xsum[%d]\n", + "file[%s], blocknum[%lld], sb_node_info.xsum[%d] != actual_xsum[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, sb_node_info.xsum, actual_xsum); dump_bad_block(rb->buf, rb->size); @@ -1774,12 +1774,12 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], deserialize_ftnode_info failed with " + "file[%s], blocknum[%lld], deserialize_ftnode_info failed with " "%d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block( static_cast(sb_node_info.uncompressed_ptr), @@ -1812,12 +1812,12 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough( fprintf( stderr, "%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - " - "file[%s], blocknum[%ld], toku_ftnode_pf_callback failed with " + "file[%s], blocknum[%lld], toku_ftnode_pf_callback failed with " "%d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block(rb->buf, rb->size); goto cleanup; @@ -2164,12 +2164,12 @@ static int deserialize_and_upgrade_ftnode(FTNODE node, const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf); fprintf(stderr, "%s:%d:deserialize_and_upgrade_ftnode - " - "file[%s], blocknum[%ld], " + "file[%s], blocknum[%lld], " "read_and_decompress_block_from_fd_into_rbuf failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); goto exit; } @@ -2190,12 +2190,12 @@ static int deserialize_and_upgrade_ftnode(FTNODE node, const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf); fprintf(stderr, "%s:%d:deserialize_and_upgrade_ftnode - " - "file[%s], blocknum[%ld], version[%d] > " + "file[%s], blocknum[%lld], version[%d] > " "FT_LAYOUT_VERSION_14[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, version, FT_LAYOUT_VERSION_14); dump_bad_block(rb.buf, rb.size); @@ -2278,12 +2278,12 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, memcmp(magic, "tokunode", 8) != 0) { fprintf(stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], unrecognized magic number " + "file[%s], blocknum[%lld], unrecognized magic number " "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, static_cast(magic)[0], static_cast(magic)[1], static_cast(magic)[2], @@ -2309,12 +2309,12 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, if (r != 0) { fprintf(stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], deserialize_and_upgrade_ftnode " + "file[%s], blocknum[%lld], deserialize_and_upgrade_ftnode " "failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block(rb->buf, rb->size); goto cleanup; @@ -2355,11 +2355,11 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, fprintf( stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], stored_checksum[%d] != checksum[%d]\n", + "file[%s], blocknum[%lld], stored_checksum[%d] != checksum[%d]\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, stored_checksum, checksum); dump_bad_block(rb->buf, rb->size); @@ -2377,12 +2377,12 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, fprintf( stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], read_and_decompress_sub_block failed " + "file[%s], blocknum[%lld], read_and_decompress_sub_block failed " "with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block( static_cast(sb_node_info.uncompressed_ptr), @@ -2398,12 +2398,12 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, fprintf( stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], deserialize_ftnode_info failed with " + "file[%s], blocknum[%lld], deserialize_ftnode_info failed with " "%d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block(rb->buf, rb->size); goto cleanup; @@ -2470,12 +2470,12 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, fprintf( stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], childnum[%d], " + "file[%s], blocknum[%lld], childnum[%d], " "decompress_and_deserialize_worker failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, i, r); dump_bad_block(rb->buf, rb->size); @@ -2490,13 +2490,13 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode, fprintf( stderr, "%s:%d:deserialize_ftnode_from_rbuf - " - "file[%s], blocknum[%ld], childnum[%d], " + "file[%s], blocknum[%lld], childnum[%d], " "check_and_copy_compressed_sub_block_worker failed with " "%d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, i, r); dump_bad_block(rb->buf, rb->size); @@ -2641,12 +2641,12 @@ int toku_deserialize_bp_from_compressed(FTNODE node, const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf); fprintf(stderr, "%s:%d:toku_deserialize_bp_from_compressed - " - "file[%s], blocknum[%ld], " + "file[%s], blocknum[%lld], " "deserialize_ftnode_partition failed with %d\n", __FILE__, __LINE__, fname ? fname : "unknown", - node->blocknum.b, + (longlong)node->blocknum.b, r); dump_bad_block(static_cast(curr_sb->compressed_ptr), curr_sb->compressed_size); @@ -2689,12 +2689,12 @@ static int deserialize_ftnode_from_fd(int fd, fprintf( stderr, "%s:%d:deserialize_ftnode_from_fd - " - "file[%s], blocknum[%ld], deserialize_ftnode_from_rbuf failed with " + "file[%s], blocknum[%lld], deserialize_ftnode_from_rbuf failed with " "%d\n", __FILE__, __LINE__, fname ? fname : "unknown", - blocknum.b, + (longlong)blocknum.b, r); dump_bad_block(rb.buf, rb.size); } diff --git a/storage/tokudb/PerconaFT/ft/tests/ft-clock-test.cc b/storage/tokudb/PerconaFT/ft/tests/ft-clock-test.cc index 26a3dae673cd9696919042e620b55c85fd2cb575..00ff8cf204bed22ccd10ede3154823f24d5fb4f4 100644 --- a/storage/tokudb/PerconaFT/ft/tests/ft-clock-test.cc +++ b/storage/tokudb/PerconaFT/ft/tests/ft-clock-test.cc @@ -184,11 +184,11 @@ static void test2(int fd, FT ft_h, FTNODE *dn) { PAIR_ATTR attr; memset(&attr, 0, sizeof(attr)); toku_ftnode_pe_callback(*dn, attr, ft_h, def_pe_finalize_impl, nullptr); - invariant(BP_STATE(*dn, 0) == (is_leaf) ? PT_ON_DISK : PT_COMPRESSED); + invariant(BP_STATE(*dn, 0) == ((is_leaf) ? PT_ON_DISK : PT_COMPRESSED)); invariant(BP_STATE(*dn, 1) == PT_AVAIL); invariant(BP_SHOULD_EVICT(*dn, 1)); toku_ftnode_pe_callback(*dn, attr, ft_h, def_pe_finalize_impl, nullptr); - invariant(BP_STATE(*dn, 1) == (is_leaf) ? PT_ON_DISK : PT_COMPRESSED); + invariant(BP_STATE(*dn, 1) == ((is_leaf) ? PT_ON_DISK : PT_COMPRESSED)); bool req = toku_ftnode_pf_req_callback(*dn, &bfe_subset); invariant(req); diff --git a/storage/tokudb/PerconaFT/ft/tests/log-test4.cc b/storage/tokudb/PerconaFT/ft/tests/log-test4.cc index e0bbedb95bf763e06d97e008434475d6b3f268a3..019852bb7291f3cb92c5ef61fdc134706f4d75c2 100644 --- a/storage/tokudb/PerconaFT/ft/tests/log-test4.cc +++ b/storage/tokudb/PerconaFT/ft/tests/log-test4.cc @@ -54,7 +54,7 @@ test_main (int argc __attribute__((__unused__)), { ml_lock(&logger->input_lock); toku_logger_make_space_in_inbuf(logger, 5); - snprintf(logger->inbuf.buf+logger->inbuf.n_in_buf, 5, "a1234"); + memcpy(logger->inbuf.buf+logger->inbuf.n_in_buf, "a1234", 5); logger->inbuf.n_in_buf+=5; logger->lsn.lsn++; logger->inbuf.max_lsn_in_buf = logger->lsn; diff --git a/storage/tokudb/PerconaFT/portability/memory.h b/storage/tokudb/PerconaFT/portability/memory.h index 5ae652d39fc52e1d00a9abc5aec54892c01966f4..851e4d69e03005b43c2a096e088d570562a1341d 100644 --- a/storage/tokudb/PerconaFT/portability/memory.h +++ b/storage/tokudb/PerconaFT/portability/memory.h @@ -107,7 +107,7 @@ size_t toku_malloc_usable_size(void *p) __attribute__((__visibility__("default") #define XMALLOC(v) CAST_FROM_VOIDP(v, toku_xmalloc(sizeof(*v))) #define XMALLOC_N(n,v) CAST_FROM_VOIDP(v, toku_xmalloc((n)*sizeof(*v))) #define XCALLOC_N(n,v) CAST_FROM_VOIDP(v, toku_xcalloc((n), (sizeof(*v)))) -#define XCALLOC(v) XCALLOC_N(1,(v)) +#define XCALLOC(v) XCALLOC_N(1,v) #define XREALLOC(v,s) CAST_FROM_VOIDP(v, toku_xrealloc(v, s)) #define XREALLOC_N(n,v) CAST_FROM_VOIDP(v, toku_xrealloc(v, (n)*sizeof(*v))) diff --git a/storage/tokudb/PerconaFT/portability/tests/test-max-data.cc b/storage/tokudb/PerconaFT/portability/tests/test-max-data.cc index dbbea974a49ff761542042187fec3704e7fccb28..fb5fc37111a77a963c9ff1ddd28a9cc298d8467d 100644 --- a/storage/tokudb/PerconaFT/portability/tests/test-max-data.cc +++ b/storage/tokudb/PerconaFT/portability/tests/test-max-data.cc @@ -64,7 +64,7 @@ int main(int argc, char *const argv[]) { if (verbose) printf("maxdata=%" PRIu64 " 0x%" PRIx64 "\n", maxdata, maxdata); // check the data size -#if defined(__x86_64__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) assert(maxdata > (1ULL << 32)); #elif __i386__ assert(maxdata < (1ULL << 32)); diff --git a/storage/tokudb/PerconaFT/portability/toku_debug_sync.h b/storage/tokudb/PerconaFT/portability/toku_debug_sync.h index b5394e58d68489eeb07c8dec61d2dc70405dbc1d..493075c36c305a5d3245fc309dccc5732993987d 100644 --- a/storage/tokudb/PerconaFT/portability/toku_debug_sync.h +++ b/storage/tokudb/PerconaFT/portability/toku_debug_sync.h @@ -62,9 +62,6 @@ inline void toku_debug_sync(struct tokutxn *txn, const char *sync_point_name) { void *client_extra; THD *thd; - if (likely(!opt_debug_sync_timeout)) - return; - toku_txn_get_client_id(txn, &client_id, &client_extra); thd = reinterpret_cast(client_extra); DEBUG_SYNC(thd, sync_point_name); diff --git a/storage/tokudb/PerconaFT/portability/toku_instrumentation.h b/storage/tokudb/PerconaFT/portability/toku_instrumentation.h index 8c9390edc0a32bcbab2d56177e1f3cc6af3aa848..c300f9275b892436b3c2c21a9e129e8bf9825013 100644 --- a/storage/tokudb/PerconaFT/portability/toku_instrumentation.h +++ b/storage/tokudb/PerconaFT/portability/toku_instrumentation.h @@ -52,6 +52,8 @@ class toku_instr_key { UU(const char *name)) {} explicit toku_instr_key(UU(pfs_key_t key_id)) {} + + ~toku_instr_key() {} }; typedef toku_instr_probe_empty toku_instr_probe; diff --git a/storage/tokudb/PerconaFT/portability/toku_portability.h b/storage/tokudb/PerconaFT/portability/toku_portability.h index 1096467a35d4097e68cbab6aceb48c44a66a64fa..8a3dcf5afc484553501bdfdff6e7f91a2d936e79 100644 --- a/storage/tokudb/PerconaFT/portability/toku_portability.h +++ b/storage/tokudb/PerconaFT/portability/toku_portability.h @@ -157,7 +157,7 @@ extern "C" { #endif // Deprecated functions. -#if !defined(TOKU_ALLOW_DEPRECATED) +#if !defined(TOKU_ALLOW_DEPRECATED) && !defined(__clang__) int creat(const char *pathname, mode_t mode) __attribute__((__deprecated__)); int fstat(int fd, struct stat *buf) __attribute__((__deprecated__)); int stat(const char *path, struct stat *buf) __attribute__((__deprecated__)); diff --git a/storage/tokudb/PerconaFT/portability/toku_pthread.h b/storage/tokudb/PerconaFT/portability/toku_pthread.h index 44de01244d256adfa6311afbd6360df26d513b6e..a0dfcc246a73dc5f6c5d51982c8596405bc8b9b2 100644 --- a/storage/tokudb/PerconaFT/portability/toku_pthread.h +++ b/storage/tokudb/PerconaFT/portability/toku_pthread.h @@ -162,18 +162,24 @@ typedef struct toku_mutex_aligned { #define ZERO_COND_INITIALIZER \ { 0 } #elif defined(__APPLE__) +#if TOKU_PTHREAD_DEBUG #define ZERO_COND_INITIALIZER \ { \ - { 0 } \ + { 0 , { 0 } }, \ + nullptr, \ + 0 \ } -#else // __linux__, at least +#else #define ZERO_COND_INITIALIZER \ { \ - { \ - { 0 } \ - } \ + { 0 , { 0 } }, \ + nullptr \ } #endif +#else // __linux__, at least +#define ZERO_COND_INITIALIZER \ + {} +#endif static inline void toku_mutexattr_init(toku_pthread_mutexattr_t *attr) { int r = pthread_mutexattr_init(attr); diff --git a/storage/tokudb/PerconaFT/portability/toku_race_tools.h b/storage/tokudb/PerconaFT/portability/toku_race_tools.h index 8482a164fb8f2d5b93b627c5fd29be94475ae1e5..96712ffffdcfab484ff863718dd8c99cd686ef74 100644 --- a/storage/tokudb/PerconaFT/portability/toku_race_tools.h +++ b/storage/tokudb/PerconaFT/portability/toku_race_tools.h @@ -40,6 +40,11 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #include +#ifdef HAVE_valgrind +#undef USE_VALGRIND +#define USE_VALGRIND 1 +#endif + #if defined(__linux__) && USE_VALGRIND # include @@ -90,8 +95,8 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. # define TOKU_ANNOTATE_IGNORE_WRITES_BEGIN() ((void) 0) # define TOKU_ANNOTATE_IGNORE_WRITES_END() ((void) 0) # define TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(mutex) +#undef RUNNING_ON_VALGRIND # define RUNNING_ON_VALGRIND (0U) - #endif // Valgrind 3.10.1 (and previous versions). diff --git a/storage/tokudb/PerconaFT/portability/toku_time.h b/storage/tokudb/PerconaFT/portability/toku_time.h index a1278ef0337312771ce047fc8d1dd0471924a827..c4c45b8e8c745016534ec126c20bca3718dfaab5 100644 --- a/storage/tokudb/PerconaFT/portability/toku_time.h +++ b/storage/tokudb/PerconaFT/portability/toku_time.h @@ -43,6 +43,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. #include #include #include +#if defined(__powerpc__) +# include +#endif static inline float toku_tdiff (struct timeval *a, struct timeval *b) { return (float)((a->tv_sec - b->tv_sec) + 1e-6 * (a->tv_usec - b->tv_usec)); @@ -106,6 +109,8 @@ static inline tokutime_t toku_time_now(void) { uint64_t result; __asm __volatile__ ("mrs %[rt], cntvct_el0" : [rt] "=r" (result)); return result; +#elif defined(__powerpc__) + return __ppc_get_timebase(); #else #error No timer implementation for this platform #endif diff --git a/storage/tokudb/PerconaFT/src/CMakeLists.txt b/storage/tokudb/PerconaFT/src/CMakeLists.txt index 65bf4814cf8554872d81394f85796abdf504a34a..bae37389004be25f3a8999e5d46d1fa22b89d89e 100644 --- a/storage/tokudb/PerconaFT/src/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/src/CMakeLists.txt @@ -18,7 +18,7 @@ set(tokudb_srcs ## make the shared library add_library(${LIBTOKUDB} SHARED ${tokudb_srcs}) add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code) -target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy ${LIBTOKUPORTABILITY}) +target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy dbug ${LIBTOKUPORTABILITY}) target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARY} ) ## make the static library diff --git a/storage/tokudb/PerconaFT/src/tests/checkpoint_stress.cc b/storage/tokudb/PerconaFT/src/tests/checkpoint_stress.cc index 135a9843ce4dedb17a539387c4e52aabc1afb2c0..d3e5ddd503160769653236ab46a6a476a1b1aae5 100644 --- a/storage/tokudb/PerconaFT/src/tests/checkpoint_stress.cc +++ b/storage/tokudb/PerconaFT/src/tests/checkpoint_stress.cc @@ -351,7 +351,7 @@ test_main (int argc, char * const argv[]) { // arg that suppresses valgrind on this child process break; } - // otherwise, fall through to an error + /* fall through */ // otherwise, fall through to an error case 'h': case '?': usage(argv[0]); diff --git a/storage/tokudb/PerconaFT/src/tests/directory_lock.cc b/storage/tokudb/PerconaFT/src/tests/directory_lock.cc index f040e680903cd191caed04647470a12e85425db4..b28a71704cf86afa85633bd8481e2749b2d1c211 100644 --- a/storage/tokudb/PerconaFT/src/tests/directory_lock.cc +++ b/storage/tokudb/PerconaFT/src/tests/directory_lock.cc @@ -69,7 +69,7 @@ static void verify_shared_ops_fail(DB_ENV* env, DB* db) { uint32_t flags = 0; DBT key,val; DBT in_key,in_val; - uint32_t in_key_data, in_val_data = 0; + uint32_t in_key_data = 0, in_val_data = 0; memset(&in_key, 0, sizeof(in_key)); memset(&in_val, 0, sizeof(in_val)); in_key.size = sizeof(in_key_data); diff --git a/storage/tokudb/PerconaFT/src/tests/loader-cleanup-test.cc b/storage/tokudb/PerconaFT/src/tests/loader-cleanup-test.cc index ea894683c232dd2fc4bd8728302e855546f3fc37..a229cb5b5651c4775db08001c2271e8552f790b8 100644 --- a/storage/tokudb/PerconaFT/src/tests/loader-cleanup-test.cc +++ b/storage/tokudb/PerconaFT/src/tests/loader-cleanup-test.cc @@ -172,12 +172,12 @@ err_type_str (enum test_type t) { case einval_o: return "open"; case enospc_fc: return "fclose"; case abort_via_poll: return "abort_via_poll"; - case commit: assert(0); - case abort_txn: assert(0); - case abort_loader: assert(0); + case commit: abort(); + case abort_txn: abort(); + case abort_loader: abort(); } // I know that Barry prefers the single-return case, but writing the code this way means that the compiler will complain if I forget something in the enum. -Bradley - assert(0); + abort(); return NULL; } @@ -193,12 +193,12 @@ err_msg_type_str (enum test_type t) { case einval_o: return "EINVAL"; case enospc_fc: return "ENOSPC"; case abort_via_poll: return "non-zero"; - case commit: assert(0); - case abort_txn: assert(0); - case abort_loader: assert(0); + case commit: abort(); + case abort_txn: abort(); + case abort_loader: abort(); } // I know that Barry prefers the single-return case, but writing the code this way means that the compiler will complain if I forget something in the enum. -Bradley - assert(0); + abort(); return NULL; } @@ -873,7 +873,7 @@ static void run_test(enum test_type t, int trigger) case abort_via_poll: poll_count_trigger = trigger; break; default: - assert(0); + abort(); } diff --git a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-abort.cc b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-abort.cc index a8455c0f4067af91e59657b58c9c8e13aeb533b9..425c12e1a90fd9293a716526f7865b1b31b74ad7 100644 --- a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-abort.cc +++ b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-abort.cc @@ -81,7 +81,7 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals memcpy(dest_key->data, &pri_data[dbnum], dest_key->size); break; default: - assert(0); + abort(); } if (dest_val) { @@ -95,9 +95,9 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals } break; case DB_DBT_REALLOC: - assert(0); + abort(); default: - assert(0); + abort(); } } diff --git a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-srcdb-fdelete-all.cc b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-srcdb-fdelete-all.cc index e823a74627d1a4fdbbeeaac4749ab5a614aa76ed..75479cb69c4118611c16301083ccba483cd66bfd 100644 --- a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-srcdb-fdelete-all.cc +++ b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple-srcdb-fdelete-all.cc @@ -85,7 +85,7 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals memcpy(dest_key->data, &pri_data[dbnum], dest_key->size); break; default: - assert(0); + abort(); } if (dest_val) { @@ -99,9 +99,9 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals } break; case DB_DBT_REALLOC: - assert(0); + abort(); default: - assert(0); + abort(); } } diff --git a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple.cc b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple.cc index c2ee80c438f24ecd78badedfb6c9e0f5c9f27d13..9f4b1cd9cb84218ff7441db6c86d4f4a4a928496 100644 --- a/storage/tokudb/PerconaFT/src/tests/recover-del-multiple.cc +++ b/storage/tokudb/PerconaFT/src/tests/recover-del-multiple.cc @@ -84,7 +84,7 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals memcpy(dest_key->data, &pri_data[dbnum], dest_key->size); break; default: - assert(0); + abort(); } if (dest_val) { @@ -98,9 +98,9 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals } break; case DB_DBT_REALLOC: - assert(0); + abort(); default: - assert(0); + abort(); } } diff --git a/storage/tokudb/PerconaFT/src/tests/recover-put-multiple-abort.cc b/storage/tokudb/PerconaFT/src/tests/recover-put-multiple-abort.cc index d045800960c05285977d099145e5f4c972057c0b..da40a61f24b73d9af9e7ebfb9c3c86fb1fa7ab66 100644 --- a/storage/tokudb/PerconaFT/src/tests/recover-put-multiple-abort.cc +++ b/storage/tokudb/PerconaFT/src/tests/recover-put-multiple-abort.cc @@ -81,7 +81,7 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals memcpy(dest_key->data, &pri_data[dbnum], dest_key->size); break; default: - assert(0); + abort(); } if (dest_val) { @@ -95,9 +95,9 @@ put_callback(DB *dest_db, DB *src_db, DBT_ARRAY *dest_keys, DBT_ARRAY *dest_vals } break; case DB_DBT_REALLOC: - assert(0); + abort(); default: - assert(0); + abort(); } } diff --git a/storage/tokudb/PerconaFT/src/tests/recovery_fileops_unit.cc b/storage/tokudb/PerconaFT/src/tests/recovery_fileops_unit.cc index cc99ab560d85ebc58e9b118b30a650a1cbbb73fe..45f0b465db49cfe3b23455b1b50325536758ada9 100644 --- a/storage/tokudb/PerconaFT/src/tests/recovery_fileops_unit.cc +++ b/storage/tokudb/PerconaFT/src/tests/recovery_fileops_unit.cc @@ -158,7 +158,7 @@ do_args(int argc, char * const argv[]) { choices[i] = -1; } - char c; + signed char c; while ((c = getopt(argc, argv, "vqhcrO:A:B:C:D:E:F:G:H:I:J:X:")) != -1) { switch (c) { case 'v': @@ -217,7 +217,7 @@ do_args(int argc, char * const argv[]) { // arg that suppresses valgrind on this child process break; } - // otherwise, fall through to an error + /* fall through */ // otherwise, fall through to an error default: usage(); break; diff --git a/storage/tokudb/PerconaFT/src/tests/test-prepare3.cc b/storage/tokudb/PerconaFT/src/tests/test-prepare3.cc index 5cb3796a26b82a34f80565e3ebf6d66e47dacd13..f57fc963529b4d83fca98638ba5abd2ffe28bbb4 100644 --- a/storage/tokudb/PerconaFT/src/tests/test-prepare3.cc +++ b/storage/tokudb/PerconaFT/src/tests/test-prepare3.cc @@ -128,6 +128,7 @@ static void check_prepared_list (enum prepared_state ps[NTXNS], long count, DB_P goto next; case PREPARED: count_prepared++; + /* fall through */ case MAYBE_COMMITTED: case MAYBE_ABORTED: count_maybe_prepared++; diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/autogen.sh b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/autogen.sh old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/compile b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/compile old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.guess b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.guess old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.rpath b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.rpath old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.sub b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/config.sub old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/depcomp b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/depcomp old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/install-sh b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/install-sh old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/ltmain.sh b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/ltmain.sh old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/missing b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/build-aux/missing old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/extra/7z2lzma/7z2lzma.bash b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/extra/7z2lzma/7z2lzma.bash old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/tests/test_compress.sh b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/tests/test_compress.sh old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/tests/test_files.sh b/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/tests/test_files.sh old mode 100644 new mode 100755 diff --git a/storage/tokudb/PerconaFT/util/dmt.cc b/storage/tokudb/PerconaFT/util/dmt.cc index b5b94982487ddecb6605f0d1ed1a4a00f00f1134..642c9367d7eae83419c04dd1ca4ce3b66f4d21f8 100644 --- a/storage/tokudb/PerconaFT/util/dmt.cc +++ b/storage/tokudb/PerconaFT/util/dmt.cc @@ -80,8 +80,8 @@ void dmt::create_from_sorted_memory_of_fix paranoid_invariant(numvalues > 0); void *ptr = toku_mempool_malloc(&this->mp, aligned_memsize); paranoid_invariant_notnull(ptr); - uint8_t * const CAST_FROM_VOIDP(dest, ptr); - const uint8_t * const CAST_FROM_VOIDP(src, mem); + uint8_t * CAST_FROM_VOIDP(dest, ptr); + const uint8_t * CAST_FROM_VOIDP(src, mem); if (pad_bytes == 0) { paranoid_invariant(aligned_memsize == mem_length); memcpy(dest, src, aligned_memsize); diff --git a/storage/tokudb/PerconaFT/util/omt.h b/storage/tokudb/PerconaFT/util/omt.h index c7ed2ca546fe131c0d66c77af85069ff10cc5a46..36946401381c2c6300c9bceff9b4f14992915fdb 100644 --- a/storage/tokudb/PerconaFT/util/omt.h +++ b/storage/tokudb/PerconaFT/util/omt.h @@ -127,7 +127,7 @@ class subtree_templated { paranoid_invariant(index != NODE_NULL); m_index = index; } -} __attribute__((__packed__,aligned(4))); +} ; template<> class subtree_templated { @@ -184,7 +184,7 @@ class subtree_templated { inline void disable_bit(void) { m_bitfield &= MASK_INDEX; } -} __attribute__((__packed__)) ; +} ; template class omt_node_templated { @@ -197,7 +197,7 @@ class omt_node_templated { // this needs to be in both implementations because we don't have // a "static if" the caller can use inline void clear_stolen_bits(void) {} -} __attribute__((__packed__,aligned(4))); +} ; template class omt_node_templated { @@ -234,7 +234,7 @@ class omt_node_templated { this->unset_marked_bit(); this->unset_marks_below_bit(); } -} __attribute__((__packed__,aligned(4))); +} ; } diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index ac0976fb1193ef4ed90cb943bae73b32de7ea54e..1016ae83ad2db6d142dfdb64719af3f4cf4f3a93 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -978,7 +978,7 @@ static bool tokudb_sync_on_prepare(void) { } static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { - TOKUDB_DBUG_ENTER(""); + TOKUDB_DBUG_ENTER("%u", all); TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); int r = 0; @@ -1006,6 +1006,22 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { r = txn->xa_prepare(txn, &thd_xid, syncflag); // test hook to induce a crash on a debug build DBUG_EXECUTE_IF("tokudb_crash_prepare_after", DBUG_SUICIDE();); + + // XA log entries can be interleaved in the binlog since XA prepare on the master + // flushes to the binlog. There can be log entries from different clients pushed + // into the binlog before XA commit is executed on the master. Therefore, the slave + // thread must be able to juggle multiple XA transactions. Tokudb does this by + // zapping the client transaction context on the slave when executing the XA prepare + // and expecting to process XA commit with commit_by_xid (which supplies the XID so + // that the transaction can be looked up and committed). + if (r == 0 && all && thd->slave_thread) { + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "zap txn context %u", thd_sql_command(thd)); + if (thd_sql_command(thd) == SQLCOM_XA_PREPARE) { + trx->all = NULL; + trx->sub_sp_level = NULL; + trx->sp_level = NULL; + } + } } else { TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "nothing to prepare %d", all); } @@ -1036,6 +1052,7 @@ static int tokudb_xa_recover(handlerton* hton, XID* xid_list, uint len) { static int tokudb_commit_by_xid(handlerton* hton, XID* xid) { TOKUDB_DBUG_ENTER(""); TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "xid %p", xid); int r = 0; DB_TXN* txn = NULL; TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid; @@ -1055,6 +1072,7 @@ static int tokudb_commit_by_xid(handlerton* hton, XID* xid) { static int tokudb_rollback_by_xid(handlerton* hton, XID* xid) { TOKUDB_DBUG_ENTER(""); TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "enter"); + TOKUDB_TRACE_FOR_FLAGS(TOKUDB_DEBUG_XA, "xid %p", xid); int r = 0; DB_TXN* txn = NULL; TOKU_XA_XID* toku_xid = (TOKU_XA_XID*)xid; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result index 9c29033429e4a13c9e8c787a73f01220ae8f3216..9276664f84f591f9fcc416b0ad2cd187bd779570 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db917.result @@ -1,8 +1,8 @@ drop table if exists t1; set @orig_table_open_cache = @@global.table_open_cache; create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); -lock tables t1 read; -set @@global.table_open_cache = 1; +lock tables t1 read,t1 as t2 read,t1 as t3 read, t1 as t4 read, t1 as t5 read, t1 as t6 read, t1 as t7 read, t1 as t8 read, t1 as t9 read, t1 as t10 read; +set @@global.table_open_cache = 10; begin; insert into t1 values(1),(1); select * from t1 where c like _ucs2 0x039C0025 collate ucs2_unicode_ci; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test index ae94d7b30de60cdc349492402ef1685ae806658d..781fdb012f136db34f683c83cad7d297b43179ab 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db917.test @@ -7,8 +7,8 @@ drop table if exists t1; enable_warnings; set @orig_table_open_cache = @@global.table_open_cache; create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); -lock tables t1 read; -set @@global.table_open_cache = 1; +lock tables t1 read,t1 as t2 read,t1 as t3 read, t1 as t4 read, t1 as t5 read, t1 as t6 read, t1 as t7 read, t1 as t8 read, t1 as t9 read, t1 as t10 read; +set @@global.table_open_cache = 10; begin; insert into t1 values(1),(1); # when the bug is present, this results in a lock wait timeout diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev6657.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev6657.result index 2e9faddbaff8347ce3db2bb1e464e3887886ea84..3804a583dc3397e371b149880a323440887cb75d 100644 --- a/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev6657.result +++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/mdev6657.result @@ -10,7 +10,7 @@ col3 smallint(5) NOT NULL DEFAULT '1', filler varchar(255) DEFAULT NULL, KEY pk_ersatz(col1,col2,col3), KEY key1 (col1,col2) USING BTREE -) ENGINE=TokuDB DEFAULT CHARSET=latin1 PACK_KEYS=1 COMPRESSION=TOKUDB_LZMA; +) ENGINE=TokuDB DEFAULT CHARSET=latin1 PACK_KEYS=1; insert into t3 select 1300000000+a, 12345, 7890, 'data' from t2; insert into t3 select 1400000000+a, 12345, 7890, 'data' from t2; insert into t3 select 1410799999+a, 12345, 7890, 'data' from t2; @@ -34,7 +34,7 @@ from t3 where col1 <= 1410799999 order by col1 desc,col2 desc,col3 desc limit 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range pk_ersatz,key1 pk_ersatz 4 NULL 2001 Using where; Using index +1 SIMPLE t3 range pk_ersatz,key1 pk_ersatz 4 NULL # Using where; Using index # The same query but the constant is bigger. # The query should use range(PRIMARY), not full index scan: explain @@ -43,5 +43,5 @@ from t3 where col1 <= 1412199999 order by col1 desc, col2 desc, col3 desc limit 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range pk_ersatz,key1 pk_ersatz 4 NULL 15001 Using where; Using index +1 SIMPLE t3 range pk_ersatz,key1 pk_ersatz 4 NULL # Using where; Using index drop table t1,t2,t3; diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev6657.test b/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev6657.test index a809c3faf063f0a97cd45509d50b3e52084ca284..b723a5d72e8a9422f235bebf9aaa34e92444004b 100644 --- a/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev6657.test +++ b/storage/tokudb/mysql-test/tokudb_mariadb/t/mdev6657.test @@ -15,7 +15,7 @@ CREATE TABLE t3 ( filler varchar(255) DEFAULT NULL, KEY pk_ersatz(col1,col2,col3), KEY key1 (col1,col2) USING BTREE -) ENGINE=TokuDB DEFAULT CHARSET=latin1 PACK_KEYS=1 COMPRESSION=TOKUDB_LZMA; +) ENGINE=TokuDB DEFAULT CHARSET=latin1 PACK_KEYS=1; insert into t3 select 1300000000+a, 12345, 7890, 'data' from t2; insert into t3 select 1400000000+a, 12345, 7890, 'data' from t2; @@ -35,6 +35,7 @@ insert into t3 select 1412099999+a, 12345, 7890, 'data' from t2; insert into t3 select 1412199999+a, 12345, 7890, 'data' from t2; --echo # The following must use range(PRIMARY): +--replace_column 9 # explain select col1,col2,col3 from t3 @@ -43,6 +44,7 @@ order by col1 desc,col2 desc,col3 desc limit 1; --echo # The same query but the constant is bigger. --echo # The query should use range(PRIMARY), not full index scan: +--replace_column 9 # explain select col1,col2,col3 from t3 diff --git a/storage/tokudb/tokudb_thread.h b/storage/tokudb/tokudb_thread.h index dec58f3fd355269cf3f7dcee6d1f0446492159f9..5df0159901f8f5a639523f19a2a921357f9f9dfa 100644 --- a/storage/tokudb/tokudb_thread.h +++ b/storage/tokudb/tokudb_thread.h @@ -111,7 +111,6 @@ class event_t { // wait for the event to become signalled void wait(void); - int wait(ulonglong microseconds); // signal the event void signal(void); @@ -152,7 +151,6 @@ class semaphore_t { // wait for the semaphore to become signalled E_WAIT wait(void); - E_WAIT wait(ulonglong microseconds); // signal the semaphore to increase the count // return true if signalled, false if ignored due to count @@ -372,28 +370,6 @@ inline void event_t::wait(void) { assert_debug(r == 0); return; } -inline int event_t::wait(ulonglong microseconds) { - timespec waittime = time::offset_timespec(microseconds); - int r = pthread_mutex_timedlock(&_mutex, &waittime); - if (r == ETIMEDOUT) return ETIMEDOUT; - assert_debug(r == 0); - while (_signalled == false && _pulsed == false) { - r = pthread_cond_timedwait(&_cond, &_mutex, &waittime); - if (r == ETIMEDOUT) { - r = pthread_mutex_unlock(&_mutex); - assert_debug(r == 0); - return ETIMEDOUT; - } - assert_debug(r == 0); - } - if (_manual_reset == false) - _signalled = false; - if (_pulsed) - _pulsed = false; - r = pthread_mutex_unlock(&_mutex); - assert_debug(r == 0); - return 0; -} inline void event_t::signal(void) { int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); @@ -479,31 +455,6 @@ inline semaphore_t::E_WAIT semaphore_t::wait(void) { assert_debug(r == 0); return ret; } -inline semaphore_t::E_WAIT semaphore_t::wait(ulonglong microseconds) { - E_WAIT ret; - timespec waittime = time::offset_timespec(microseconds); - int r = pthread_mutex_timedlock(&_mutex, &waittime); - if (r == ETIMEDOUT) return E_TIMEDOUT; - assert_debug(r == 0); - while (_signalled == 0 && _interrupted == false) { - r = pthread_cond_timedwait(&_cond, &_mutex, &waittime); - if (r == ETIMEDOUT) { - r = pthread_mutex_unlock(&_mutex); - assert_debug(r == 0); - return E_TIMEDOUT; - } - assert_debug(r == 0); - } - if (_interrupted) { - ret = E_INTERRUPTED; - } else { - _signalled--; - ret = E_SIGNALLED; - } - r = pthread_mutex_unlock(&_mutex); - assert_debug(r == 0); - return ret; -} inline bool semaphore_t::signal(void) { bool ret = false; int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex); diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 67d068748d22e5e782854730f173c8027c362f6a..f5ec6fd746d5b0b226d799b1feea804333689a68 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -509,9 +509,11 @@ MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} ${LINKER_SCRIPT}) -IF(TARGET xtradb AND NOT XTRADB_OK) - MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") +IF(TARGET xtradb) + IF(NOT XTRADB_OK) + MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") + ENDIF() + ADD_DEPENDENCIES(xtradb GenError) ENDIF() ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/extra/mariabackup ${CMAKE_BINARY_DIR}/extra/mariabackup) - diff --git a/storage/xtradb/btr/btr0defragment.cc b/storage/xtradb/btr/btr0defragment.cc index 44acd9118d7898703b9e5c9a9343b75cb14b05d0..3124db650c6e2ec984c99c8f3f0de593f7bd91e7 100644 --- a/storage/xtradb/btr/btr0defragment.cc +++ b/storage/xtradb/btr/btr0defragment.cc @@ -40,56 +40,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com #include -/**************************************************//** -Custom nullptr implementation for under g++ 4.6 -*******************************************************/ -/* -// #pragma once -namespace std -{ - // based on SC22/WG21/N2431 = J16/07-0301 - struct nullptr_t - { - template operator any * () const - { - return 0; - } - template operator T any:: * () const - { - return 0; - } - -#ifdef _MSC_VER - struct pad {}; - pad __[sizeof(void*)/sizeof(pad)]; -#else - char __[sizeof(void*)]; -#endif -private: - // nullptr_t();// {} - // nullptr_t(const nullptr_t&); - // void operator = (const nullptr_t&); - void operator &() const; - template void operator +(any) const - { - // I Love MSVC 2005! - } - template void operator -(any) const - { - // I Love MSVC 2005! - } - }; -static const nullptr_t __nullptr = {}; -} - -#ifndef nullptr -#define nullptr std::__nullptr -#endif -*/ -/**************************************************//** -End of Custom nullptr implementation for under g++ 4.6 -*******************************************************/ - /* When there's no work, either because defragment is disabled, or because no query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ #define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 diff --git a/storage/xtradb/btr/btr0sea.cc b/storage/xtradb/btr/btr0sea.cc index 12c99246f1617d875e9e884609cd63d442bab881..713a584ee7e0885e77d192397eaded0c242848bb 100644 --- a/storage/xtradb/btr/btr0sea.cc +++ b/storage/xtradb/btr/btr0sea.cc @@ -2,6 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. +Copyright (c) 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -1299,17 +1300,11 @@ btr_search_drop_page_hash_index( mem_free(folds); } -/********************************************************************//** -Drops a possible page hash index when a page is evicted from the buffer pool -or freed in a file segment. */ +/** Drop possible adaptive hash index entries when a page is evicted +from the buffer pool or freed in a file, or the index is being dropped. */ UNIV_INTERN void -btr_search_drop_page_hash_when_freed( -/*=================================*/ - ulint space, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ - ulint page_no) /*!< in: page number */ +btr_search_drop_page_hash_when_freed(ulint space, ulint page_no) { buf_block_t* block; mtr_t mtr; @@ -1322,7 +1317,7 @@ btr_search_drop_page_hash_when_freed( are possibly holding, we cannot s-latch the page, but must (recursively) x-latch it, even though we are only reading. */ - block = buf_page_get_gen(space, zip_size, page_no, RW_X_LATCH, NULL, + block = buf_page_get_gen(space, 0, page_no, RW_X_LATCH, NULL, BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__, &mtr); diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 80ff1c14a64b2d3aad950a50787d86207c5dc436..3ae6dd56586470d338a5506ced7a605f426aef03 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -77,15 +77,6 @@ Created 11/5/1995 Heikki Tuuri #include "snappy-c.h" #endif -/** Decrypt a page. -@param[in,out] bpage Page control block -@param[in,out] space tablespace -@return whether the operation was successful */ -static -bool -buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) - MY_ATTRIBUTE((nonnull)); - /********************************************************************//** Mark a table with the specified space pointed by bpage->space corrupted. Also remove the bpage from LRU list. @@ -390,6 +381,143 @@ on the io_type */ ? (counter##_READ) \ : (counter##_WRITTEN)) + +/** Reserve a buffer slot for encryption, decryption or page compression. +@param[in,out] buf_pool buffer pool +@return reserved buffer slot */ +static buf_tmp_buffer_t* buf_pool_reserve_tmp_slot(buf_pool_t* buf_pool) +{ + for (ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) { + buf_tmp_buffer_t* slot = &buf_pool->tmp_arr->slots[i]; + if (slot->acquire()) { + return slot; + } + } + + /* We assume that free slot is found */ + ut_error; + return NULL; +} + +/** Reserve a buffer for encryption, decryption or decompression. +@param[in,out] slot reserved slot */ +static void buf_tmp_reserve_crypt_buf(buf_tmp_buffer_t* slot) +{ + if (!slot->crypt_buf) { + slot->crypt_buf = static_cast( + aligned_malloc(srv_page_size, srv_page_size)); + } +} + +/** Reserve a buffer for compression. +@param[in,out] slot reserved slot */ +static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot) +{ + if (!slot->comp_buf) { + /* Both snappy and lzo compression methods require that + output buffer used for compression is bigger than input + buffer. Increase the allocated buffer size accordingly. */ + ulint size = srv_page_size; +#ifdef HAVE_LZO + size += LZO1X_1_15_MEM_COMPRESS; +#elif defined HAVE_SNAPPY + size = snappy_max_compressed_length(size); +#endif + slot->comp_buf = static_cast( + aligned_malloc(size, srv_page_size)); + } +} + +/** Decrypt a page. +@param[in,out] bpage Page control block +@param[in,out] space tablespace +@return whether the operation was successful */ +static bool buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) +{ + ut_ad(space->n_pending_ios > 0); + ut_ad(space->id == bpage->space); + + byte* dst_frame = bpage->zip.data ? bpage->zip.data : + ((buf_block_t*) bpage)->frame; + bool page_compressed = fil_page_is_compressed(dst_frame); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + if (bpage->offset == 0) { + /* File header pages are not encrypted/compressed */ + return true; + } + + /* Page is encrypted if encryption information is found from + tablespace and page contains used key_version. This is true + also for pages first compressed and then encrypted. */ + + buf_tmp_buffer_t* slot; + + if (page_compressed) { + /* the page we read is unencrypted */ + /* Find free slot from temporary memory array */ +decompress: + slot = buf_pool_reserve_tmp_slot(buf_pool); + /* For decompression, use crypt_buf. */ + buf_tmp_reserve_crypt_buf(slot); +decompress_with_slot: + ut_d(fil_page_type_validate(dst_frame)); + + bpage->write_size = fil_page_decompress(slot->crypt_buf, + dst_frame); + slot->release(); + + ut_ad(!bpage->write_size || fil_page_type_validate(dst_frame)); + ut_ad(space->n_pending_ios > 0); + return bpage->write_size != 0; + } + + if (space->crypt_data + && mach_read_from_4(FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + + dst_frame)) { + /* Verify encryption checksum before we even try to + decrypt. */ + if (!fil_space_verify_crypt_checksum( + dst_frame, buf_page_get_zip_size(bpage), NULL, + bpage->offset)) { +decrypt_failed: + /* Mark page encrypted in case it should be. */ + if (space->crypt_data->type + != CRYPT_SCHEME_UNENCRYPTED) { + bpage->encrypted = true; + } + + return false; + } + + /* Find free slot from temporary memory array */ + slot = buf_pool_reserve_tmp_slot(buf_pool); + buf_tmp_reserve_crypt_buf(slot); + + ut_d(fil_page_type_validate(dst_frame)); + + /* decrypt using crypt_buf to dst_frame */ + if (!fil_space_decrypt(space, slot->crypt_buf, + dst_frame, &bpage->encrypted)) { + slot->release(); + goto decrypt_failed; + } + + ut_d(fil_page_type_validate(dst_frame)); + + if (fil_page_is_compressed_encrypted(dst_frame)) { + goto decompress_with_slot; + } + + slot->release(); + } else if (fil_page_is_compressed_encrypted(dst_frame)) { + goto decompress; + } + + ut_ad(space->n_pending_ios > 0); + return true; +} + /********************************************************************//** Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk. @@ -2969,17 +3097,18 @@ buf_page_get_gen( #ifdef UNIV_DEBUG switch (mode) { case BUF_EVICT_IF_IN_POOL: + case BUF_PEEK_IF_IN_POOL: /* After DISCARD TABLESPACE, the tablespace would not exist, but in IMPORT TABLESPACE, PageConverter::operator() must replace any old pages, which were not evicted during DISCARD. - Skip the assertion on zip_size. */ + Similarly, btr_search_drop_page_hash_when_freed() must + remove any old pages. Skip the assertion on zip_size. */ break; case BUF_GET_NO_LATCH: ut_ad(rw_latch == RW_NO_LATCH); /* fall through */ case BUF_GET: case BUF_GET_IF_IN_POOL: - case BUF_PEEK_IF_IN_POOL: case BUF_GET_IF_IN_POOL_OR_WATCH: case BUF_GET_POSSIBLY_FREED: ut_ad(zip_size == fil_space_get_zip_size(space)); @@ -3088,6 +3217,11 @@ buf_page_get_gen( ibuf_inside(mtr), trx); retries = 0; + } else if (mode == BUF_GET_POSSIBLY_FREED) { + if (err) { + *err = local_err; + } + return NULL; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; @@ -3151,7 +3285,8 @@ buf_page_get_gen( fix_mutex = buf_page_get_mutex(&fix_block->page); - ut_ad(page_zip_get_size(&block->page.zip) == zip_size); + ut_ad(page_zip_get_size(&block->page.zip) == zip_size + || mode == BUF_PEEK_IF_IN_POOL); switch (mode) { case BUF_GET_IF_IN_POOL: @@ -3369,6 +3504,8 @@ buf_page_get_gen( mutex_enter(&buf_pool->LRU_list_mutex); buf_block_unfix(fix_block); mutex_exit(&buf_pool->LRU_list_mutex); + + *err = DB_PAGE_CORRUPTED; return NULL; } } @@ -4684,9 +4821,9 @@ buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) ib_logf(IB_LOG_LEVEL_ERROR, "The page [page id: space=%u" ", page number=%u]" - " in file %s cannot be decrypted.", + " in file '%s' cannot be decrypted.", bpage->space, bpage->offset, - space->name); + space->chain.start->name); ib_logf(IB_LOG_LEVEL_INFO, "However key management plugin or used key_version " ULINTPF @@ -4721,7 +4858,6 @@ buf_page_io_complete(buf_page_t* bpage) const ibool uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); bool have_LRU_mutex = false; - byte* frame = NULL; dberr_t err = DB_SUCCESS; ut_a(buf_page_in_file(bpage)); @@ -4739,19 +4875,18 @@ buf_page_io_complete(buf_page_t* bpage) ulint read_page_no = 0; ulint read_space_id = 0; uint key_version = 0; - - ut_ad(bpage->zip.data || ((buf_block_t*)bpage)->frame); + byte* frame = bpage->zip.data + ? bpage->zip.data + : reinterpret_cast(bpage)->frame; + ut_ad(frame); fil_space_t* space = fil_space_acquire_for_io(bpage->space); if (!space) { return(DB_TABLESPACE_DELETED); } - buf_page_decrypt_after_read(bpage, space); - - if (buf_page_get_zip_size(bpage)) { - frame = bpage->zip.data; - } else { - frame = ((buf_block_t*) bpage)->frame; + if (!buf_page_decrypt_after_read(bpage, space)) { + err = DB_DECRYPTION_FAILED; + goto database_corrupted; } if (buf_page_get_zip_size(bpage)) { @@ -4932,7 +5067,7 @@ buf_page_io_complete(buf_page_t* bpage) /* io_type == BUF_IO_WRITE */ if (bpage->slot) { /* Mark slot free */ - bpage->slot->reserved = false; + bpage->slot->release(); bpage->slot = NULL; } } @@ -6231,66 +6366,6 @@ buf_pool_mutex_exit( mutex_exit(&buf_pool->LRU_list_mutex); } -/********************************************************************//** -Reserve unused slot from temporary memory array and allocate necessary -temporary memory if not yet allocated. -@return reserved slot */ -UNIV_INTERN -buf_tmp_buffer_t* -buf_pool_reserve_tmp_slot( -/*======================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool where to - reserve */ - bool compressed) /*!< in: is file space compressed */ -{ - buf_tmp_buffer_t *free_slot=NULL; - - /* Array is protected by buf_pool mutex */ - buf_pool_mutex_enter(buf_pool); - - for(ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) { - buf_tmp_buffer_t *slot = &buf_pool->tmp_arr->slots[i]; - - if(slot->reserved == false) { - free_slot = slot; - break; - } - } - - /* We assume that free slot is found */ - ut_a(free_slot != NULL); - free_slot->reserved = true; - /* Now that we have reserved this slot we can release - buf_pool mutex */ - buf_pool_mutex_exit(buf_pool); - - /* Allocate temporary memory for encryption/decryption */ - if (free_slot->crypt_buf == NULL) { - free_slot->crypt_buf = static_cast(aligned_malloc(UNIV_PAGE_SIZE, UNIV_PAGE_SIZE)); - memset(free_slot->crypt_buf, 0, UNIV_PAGE_SIZE); - } - - /* For page compressed tables allocate temporary memory for - compression/decompression */ - if (compressed && free_slot->comp_buf == NULL) { - ulint size = UNIV_PAGE_SIZE; - - /* Both snappy and lzo compression methods require that - output buffer used for compression is bigger than input - buffer. Increase the allocated buffer size accordingly. */ -#if HAVE_SNAPPY - size = snappy_max_compressed_length(size); -#endif -#if HAVE_LZO - size += LZO1X_1_15_MEM_COMPRESS; -#endif - free_slot->comp_buf = static_cast(aligned_malloc(size, UNIV_PAGE_SIZE)); - memset(free_slot->comp_buf, 0, size); - } - - return (free_slot); -} - /** Encryption and page_compression hook that is called just before a page is written to disk. @param[in,out] space tablespace @@ -6340,16 +6415,18 @@ buf_page_encrypt_before_write( } ulint zip_size = buf_page_get_zip_size(bpage); - ulint page_size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; + ut_ad(!zip_size || !page_compressed); buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); /* Find free slot from temporary memory array */ - buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); + buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool); slot->out_buf = NULL; bpage->slot = slot; + buf_tmp_reserve_crypt_buf(slot); byte *dst_frame = slot->crypt_buf; if (!page_compressed) { +not_compressed: /* Encrypt page content */ byte* tmp = fil_space_encrypt(space, bpage->offset, @@ -6357,32 +6434,28 @@ buf_page_encrypt_before_write( src_frame, dst_frame); - bpage->real_size = page_size; + bpage->real_size = UNIV_PAGE_SIZE; slot->out_buf = dst_frame = tmp; ut_d(fil_page_type_validate(tmp)); } else { /* First we compress the page content */ - ulint out_len = 0; - - byte *tmp = fil_compress_page( - space, - (byte *)src_frame, - slot->comp_buf, - page_size, + buf_tmp_reserve_compression_buf(slot); + byte* tmp = slot->comp_buf; + ulint out_len = fil_page_compress( + src_frame, tmp, fsp_flags_get_page_compression_level(space->flags), fil_space_get_block_size(space, bpage->offset), - encrypted, - &out_len); + encrypted); + if (!out_len) { + goto not_compressed; + } bpage->real_size = out_len; -#ifdef UNIV_DEBUG - fil_page_type_validate(tmp); -#endif - - if(encrypted) { + ut_d(fil_page_type_validate(tmp)); + if (encrypted) { /* And then we encrypt the page content */ tmp = fil_space_encrypt(space, bpage->offset, @@ -6394,130 +6467,8 @@ buf_page_encrypt_before_write( slot->out_buf = dst_frame = tmp; } -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif + ut_d(fil_page_type_validate(dst_frame)); // return dst_frame which will be written return dst_frame; } - -/** Decrypt a page. -@param[in,out] bpage Page control block -@param[in,out] space tablespace -@return whether the operation was successful */ -static -bool -buf_page_decrypt_after_read(buf_page_t* bpage, fil_space_t* space) -{ - ut_ad(space->n_pending_ios > 0); - ut_ad(space->id == bpage->space); - - ulint zip_size = buf_page_get_zip_size(bpage); - ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; - - byte* dst_frame = (zip_size) ? bpage->zip.data : - ((buf_block_t*) bpage)->frame; - unsigned key_version = - mach_read_from_4(dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - bool page_compressed = fil_page_is_compressed(dst_frame); - bool page_compressed_encrypted = fil_page_is_compressed_encrypted(dst_frame); - buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - bool success = true; - - if (bpage->offset == 0) { - /* File header pages are not encrypted/compressed */ - return (true); - } - - /* Page is encrypted if encryption information is found from - tablespace and page contains used key_version. This is true - also for pages first compressed and then encrypted. */ - if (!space->crypt_data) { - key_version = 0; - } - - if (page_compressed) { - /* the page we read is unencrypted */ - /* Find free slot from temporary memory array */ - buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - - /* decompress using comp_buf to dst_frame */ - fil_decompress_page(slot->comp_buf, - dst_frame, - ulong(size), - &bpage->write_size); - - /* Mark this slot as free */ - slot->reserved = false; - key_version = 0; - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - } else { - buf_tmp_buffer_t* slot = NULL; - - if (key_version) { - /* Verify encryption checksum before we even try to - decrypt. */ - if (!fil_space_verify_crypt_checksum(dst_frame, - zip_size, NULL, bpage->offset)) { - - /* Mark page encrypted in case it should - be. */ - if (space->crypt_data->type - != CRYPT_SCHEME_UNENCRYPTED) { - bpage->encrypted = true; - } - - return (false); - } - - /* Find free slot from temporary memory array */ - slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - - /* decrypt using crypt_buf to dst_frame */ - if (!fil_space_decrypt(space, slot->crypt_buf, - dst_frame, &bpage->encrypted)) { - success = false; - } - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - } - - if (page_compressed_encrypted && success) { - if (!slot) { - slot = buf_pool_reserve_tmp_slot(buf_pool, page_compressed); - } - -#ifdef UNIV_DEBUG - fil_page_type_validate(dst_frame); -#endif - /* decompress using comp_buf to dst_frame */ - fil_decompress_page(slot->comp_buf, - dst_frame, - ulong(size), - &bpage->write_size); - ut_d(fil_page_type_validate(dst_frame)); - } - - /* Mark this slot as free */ - if (slot) { - slot->reserved = false; - } - } - - ut_ad(space->n_pending_ios > 0); - return (success); -} diff --git a/storage/xtradb/buf/buf0dblwr.cc b/storage/xtradb/buf/buf0dblwr.cc index ee8c85446e9d34e5b2a1cb733e6cdfe1cd8c24af..0ec23cbdbe1f04dcf92db12694df11f11d45100e 100644 --- a/storage/xtradb/buf/buf0dblwr.cc +++ b/storage/xtradb/buf/buf0dblwr.cc @@ -510,10 +510,11 @@ buf_dblwr_process() "Restoring possible half-written data pages " "from the doublewrite buffer..."); - unaligned_read_buf = static_cast(ut_malloc(2 * UNIV_PAGE_SIZE)); + unaligned_read_buf = static_cast(ut_malloc(3 * UNIV_PAGE_SIZE)); read_buf = static_cast( ut_align(unaligned_read_buf, UNIV_PAGE_SIZE)); + byte* const buf = read_buf + UNIV_PAGE_SIZE; for (std::list::iterator i = recv_dblwr.pages.begin(); i != recv_dblwr.pages.end(); ++i, ++page_no_dblwr ) { @@ -562,24 +563,26 @@ buf_dblwr_process() ignore this page (there should be redo log records to initialize it). */ } else { - if (fil_page_is_compressed_encrypted(read_buf) || - fil_page_is_compressed(read_buf)) { - /* Decompress the page before - validating the checksum. */ - fil_decompress_page( - NULL, read_buf, srv_page_size, - NULL, true); + /* Decompress the page before + validating the checksum. */ + ulint decomp = fil_page_decompress(buf, read_buf); + if (!decomp) { + goto bad; + } + if (!decomp || (decomp != srv_page_size && zip_size)) { + goto bad; } if (fil_space_verify_crypt_checksum( - read_buf, zip_size, NULL, page_no) - || !buf_page_is_corrupted( - true, read_buf, zip_size, space())) { + read_buf, zip_size, NULL, page_no) + || !buf_page_is_corrupted( + true, read_buf, zip_size, space())) { /* The page is good; there is no need to consult the doublewrite buffer. */ continue; } +bad: /* We intentionally skip this message for is_all_zero pages. */ ib_logf(IB_LOG_LEVEL_INFO, @@ -588,18 +591,15 @@ buf_dblwr_process() space_id, page_no); } - /* Next, validate the doublewrite page. */ - if (fil_page_is_compressed_encrypted(page) || - fil_page_is_compressed(page)) { - /* Decompress the page before - validating the checksum. */ - fil_decompress_page( - NULL, page, srv_page_size, NULL, true); + ulint decomp = fil_page_decompress(buf, page); + if (!decomp || (decomp != srv_page_size && zip_size)) { + goto bad_doublewrite; } - - if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, page_no) + if (!fil_space_verify_crypt_checksum(page, zip_size, NULL, + page_no) && buf_page_is_corrupted(true, page, zip_size, space)) { if (!is_all_zero) { +bad_doublewrite: ib_logf(IB_LOG_LEVEL_WARN, "A doublewrite copy of page " ULINTPF ":" ULINTPF " is corrupted.", diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index bf384390a9823adeed76d97c5da1847bc9c435e4..ce21a30896087d7e594229831cf4bdf1fe12a20a 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -42,6 +42,7 @@ Created April 08, 2011 Vasil Dimov #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ #include "mysql/service_wsrep.h" /* wsrep_recovery */ +#include enum status_severity { STATUS_INFO, @@ -216,7 +217,20 @@ buf_dump( buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s", full_filename); - f = fopen(tmp_filename, "w"); +#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0 + f = fopen(tmp_filename, "w" STR_O_CLOEXEC); +#else + { + int fd; + fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640); + if (fd >= 0) { + f = fdopen(fd, "w"); + } + else { + f = NULL; + } + } +#endif if (f == NULL) { buf_dump_status(STATUS_ERR, "Cannot open '%s' for writing: %s", @@ -320,6 +334,14 @@ buf_dump( i + 1, srv_buf_pool_instances, j + 1, n_pages); } + if ( (j % 1024) == 0) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Dumping buffer pool " + ULINTPF "/" ULINTPF ", " + "page " ULINTPF "/" ULINTPF, + i + 1, srv_buf_pool_instances, + j + 1, n_pages); + } } ut_free(dump); diff --git a/storage/xtradb/buf/buf0flu.cc b/storage/xtradb/buf/buf0flu.cc index abbcd5141cf613bee42744fe6359f631e2a21f7c..de59bbcd4c0b1a017f906299cfcc08112438bb7c 100644 --- a/storage/xtradb/buf/buf0flu.cc +++ b/storage/xtradb/buf/buf0flu.cc @@ -54,6 +54,8 @@ Created 11/11/1995 Heikki Tuuri #include "mysql/service_thd_wait.h" #include "fil0pagecompress.h" +#include + /** Number of pages flushed through non flush_list flushes. */ // static ulint buf_lru_flush_page_count = 0; @@ -575,6 +577,17 @@ buf_flush_remove( buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ulint zip_size; +#if 0 // FIXME: Rate-limit the output. Move this to the page cleaner? + if (UNIV_UNLIKELY(srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE)) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "Flush and remove page with tablespace id %u" + ", Poolid " ULINTPF ", flush list length " ULINTPF, + bpage->space, buf_pool->instance_no, + UT_LIST_GET_LEN(buf_pool->flush_list)); + } +#endif + ut_ad(mutex_own(buf_page_get_mutex(bpage))); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG ut_ad(buf_page_get_state(bpage) != BUF_BLOCK_ZIP_DIRTY diff --git a/storage/xtradb/buf/buf0lru.cc b/storage/xtradb/buf/buf0lru.cc index 7bf423ed7405493ec6b0954aa21ea6fd09b8ebde..2c4a4049de633db1fe355aa7fa83dcfd1f1223bf 100644 --- a/storage/xtradb/buf/buf0lru.cc +++ b/storage/xtradb/buf/buf0lru.cc @@ -238,8 +238,6 @@ void buf_LRU_drop_page_hash_batch( /*=========================*/ ulint space_id, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ const ulint* arr, /*!< in: array of page_no */ ulint count) /*!< in: number of entries in array */ { @@ -249,8 +247,7 @@ buf_LRU_drop_page_hash_batch( ut_ad(count <= BUF_LRU_DROP_SEARCH_SIZE); for (i = 0; i < count; ++i) { - btr_search_drop_page_hash_when_freed(space_id, zip_size, - arr[i]); + btr_search_drop_page_hash_when_freed(space_id, arr[i]); } } @@ -269,15 +266,6 @@ buf_LRU_drop_page_hash_for_tablespace( buf_page_t* bpage; ulint* page_arr; ulint num_entries; - ulint zip_size; - - zip_size = fil_space_get_zip_size(id); - - if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { - /* Somehow, the tablespace does not exist. Nothing to drop. */ - ut_ad(0); - return; - } page_arr = static_cast(ut_malloc( sizeof(ulint) * BUF_LRU_DROP_SEARCH_SIZE)); @@ -331,8 +319,7 @@ buf_LRU_drop_page_hash_for_tablespace( the latching order. */ mutex_exit(&buf_pool->LRU_list_mutex); - buf_LRU_drop_page_hash_batch( - id, zip_size, page_arr, num_entries); + buf_LRU_drop_page_hash_batch(id, page_arr, num_entries); num_entries = 0; @@ -363,10 +350,32 @@ buf_LRU_drop_page_hash_for_tablespace( mutex_exit(&buf_pool->LRU_list_mutex); /* Drop any remaining batch of search hashed pages. */ - buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries); + buf_LRU_drop_page_hash_batch(id, page_arr, num_entries); ut_free(page_arr); } +/** Drop the adaptive hash index for a tablespace. +@param[in,out] table table */ +UNIV_INTERN void buf_LRU_drop_page_hash_for_tablespace(dict_table_t* table) +{ + for (dict_index_t* index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + if (btr_search_info_get_ref_count(btr_search_get_info(index), + index)) { + goto drop_ahi; + } + } + + return; +drop_ahi: + ulint id = table->space; + for (ulint i = 0; i < srv_buf_pool_instances; i++) { + buf_LRU_drop_page_hash_for_tablespace(buf_pool_from_array(i), + id); + } +} + /******************************************************************//** While flushing (or removing dirty) pages from a tablespace we don't want to hog the CPU and resources. Release the buffer pool and block @@ -733,18 +742,11 @@ buf_flush_dirty_pages(buf_pool_t* buf_pool, ulint id, const trx_t* trx) /** Empty the flush list for all pages belonging to a tablespace. @param[in] id tablespace identifier @param[in] trx transaction, for checking for user interrupt; - or NULL if nothing is to be written -@param[in] drop_ahi whether to drop the adaptive hash index */ -UNIV_INTERN -void -buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx, bool drop_ahi) + or NULL if nothing is to be written */ +UNIV_INTERN void buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_t* buf_pool = buf_pool_from_array(i); - if (drop_ahi) { - buf_LRU_drop_page_hash_for_tablespace(buf_pool, id); - } - buf_flush_dirty_pages(buf_pool, id, trx); + buf_flush_dirty_pages(buf_pool_from_array(i), id, trx); } if (trx && !trx_is_interrupted(trx)) { diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc index 6d5b12474ebbd0b95f40e794061219a40af5dc78..2fe9f8af4ecb03cd0c7bc8e871fc732179e43a43 100644 --- a/storage/xtradb/dict/dict0crea.cc +++ b/storage/xtradb/dict/dict0crea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -327,10 +327,8 @@ dict_build_table_def_step( mtr_commit(&mtr); } else { - /* Create in the system tablespace: disallow Barracuda - features by keeping only the first bit which says whether - the row format is redundant or compact */ - table->flags &= DICT_TF_COMPACT; + /* Create in the system tablespace */ + ut_ad(table->space == TRX_SYS_SPACE); } row = dict_create_sys_tables_tuple(table, node->heap); diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index 9257321c7eff14f6eb69aefcbf9daee16fb8ea2a..7ade6d79adfa9ef2e384dbc8451117509fa54b4b 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -1,8 +1,8 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -507,7 +507,8 @@ dict_table_try_drop_aborted( ut_ad(table->id == table_id); } - if (table && table->n_ref_count == ref_count && table->drop_aborted) { + if (table && table->n_ref_count == ref_count && table->drop_aborted + && !UT_LIST_GET_FIRST(table->locks)) { /* Silence a debug assertion in row_merge_drop_indexes(). */ ut_d(table->n_ref_count++); row_merge_drop_indexes(trx, table, TRUE); @@ -1679,7 +1680,7 @@ dict_table_rename_in_cache( filepath = fil_make_ibd_name(table->name, false); } - fil_delete_tablespace(table->space, true); + fil_delete_tablespace(table->space); /* Delete any temp file hanging around. */ if (os_file_status(filepath, &exists, &ftype) @@ -2080,6 +2081,30 @@ dict_table_remove_from_cache_low( foreign->referenced_index = NULL; } + /* The check for dropped index should happen before we release + all the indexes */ + + if (lru_evict && table->drop_aborted) { + /* When evicting the table definition, + drop the orphan indexes from the data dictionary + and free the index pages. */ + trx_t* trx = trx_allocate_for_background(); + + ut_ad(mutex_own(&dict_sys->mutex)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ + /* Mimic row_mysql_lock_data_dictionary(). */ + trx->dict_operation_lock_mode = RW_X_LATCH; + + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + row_merge_drop_indexes_dict(trx, table->id); + + trx_commit_for_mysql(trx); + trx->dict_operation_lock_mode = 0; + trx_free_for_background(trx); + } + /* Remove the indexes from the cache */ for (index = UT_LIST_GET_LAST(table->indexes); @@ -2112,27 +2137,6 @@ dict_table_remove_from_cache_low( dict_table_autoinc_store(table); } - if (lru_evict && table->drop_aborted) { - /* When evicting the table definition, - drop the orphan indexes from the data dictionary - and free the index pages. */ - trx_t* trx = trx_allocate_for_background(); - - ut_ad(mutex_own(&dict_sys->mutex)); -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - /* Mimic row_mysql_lock_data_dictionary(). */ - trx->dict_operation_lock_mode = RW_X_LATCH; - - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); - row_merge_drop_indexes_dict(trx, table->id); - - trx_commit_for_mysql(trx); - trx->dict_operation_lock_mode = 0; - trx_free_for_background(trx); - } - dict_mem_table_free(table); } @@ -2725,36 +2729,12 @@ dict_index_remove_from_cache_low( zero. See also: dict_table_can_be_evicted() */ do { - ulint ref_count = btr_search_info_get_ref_count(info, - index); - - if (ref_count == 0) { + if (!btr_search_info_get_ref_count(info, index)) { break; } - /* Sleep for 10ms before trying again. */ - os_thread_sleep(10000); - ++retries; - - if (retries % 500 == 0) { - /* No luck after 5 seconds of wait. */ - fprintf(stderr, "InnoDB: Error: Waited for" - " %lu secs for hash index" - " ref_count (%lu) to drop" - " to 0.\n" - "index: \"%s\"" - " table: \"%s\"\n", - retries/100, - ref_count, - index->name, - table->name); - } - - /* To avoid a hang here we commit suicide if the - ref_count doesn't drop to zero in 600 seconds. */ - if (retries >= 60000) { - ut_error; - } + buf_LRU_drop_page_hash_for_tablespace(table); + ut_a(++retries < 10000); } while (srv_shutdown_state == SRV_SHUTDOWN_NONE || !lru_evict); rw_lock_free(&index->lock); diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc index 6171bbd80d027ecc98349ef9e50854158c92d4b7..fb14a9058a5001d5cf0084b6766967d2e7534330 100644 --- a/storage/xtradb/dict/dict0load.cc +++ b/storage/xtradb/dict/dict0load.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, 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 @@ -2088,10 +2088,12 @@ dict_load_table_low( ulint flags2; if (rec_get_deleted_flag(rec, 0)) { + *table = NULL; return("delete-marked record in SYS_TABLES"); } if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_TABLES) { + *table = NULL; return("wrong number of columns in SYS_TABLES record"); } @@ -2099,6 +2101,7 @@ dict_load_table_low( rec, DICT_FLD__SYS_TABLES__NAME, &len); if (len == 0 || len == UNIV_SQL_NULL) { err_len: + *table = NULL; return("incorrect column length in SYS_TABLES"); } rec_get_nth_field_offs_old( @@ -2178,6 +2181,7 @@ dict_load_table_low( "InnoDB: in InnoDB data dictionary" " has unknown type %lx.\n", (ulong) flags); + *table = NULL; return("incorrect flags in SYS_TABLES"); } diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index cf27caf6c28f00bca646b746592073f9dc42531c..ab6167b920b63778f728afedc5e67ffc6de47903 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2018, MariaDB Corporation. diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index 3095503cfc5569a81528249c9c024f2503b4d68d..932d7b9e31209988f3943aaca7d74c25d1bcfce4 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1,6 +1,6 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2014, 2018, MariaDB Corporation. All Rights Reserved. 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 @@ -114,17 +114,17 @@ extern my_bool srv_background_scrub_data_compressed; /*********************************************************************** Check if a key needs rotation given a key_state -@param[in] encrypt_mode Encryption mode +@param[in] crypt_data Encryption information @param[in] key_version Current key version @param[in] latest_key_version Latest key version @param[in] rotate_key_age when to rotate @return true if key needs rotation, false if not */ static bool fil_crypt_needs_rotation( - fil_encryption_t encrypt_mode, - uint key_version, - uint latest_key_version, - uint rotate_key_age) + const fil_space_crypt_t* crypt_data, + uint key_version, + uint latest_key_version, + uint rotate_key_age) MY_ATTRIBUTE((warn_unused_result)); /********************************************************************* @@ -187,7 +187,8 @@ fil_crypt_get_latest_key_version( if (crypt_data->is_key_found()) { - if (fil_crypt_needs_rotation(crypt_data->encryption, + if (fil_crypt_needs_rotation( + crypt_data, crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { @@ -707,60 +708,39 @@ fil_space_encrypt( #ifdef UNIV_DEBUG if (tmp) { /* Verify that encrypted buffer is not corrupted */ - byte* tmp_mem = (byte *)malloc(UNIV_PAGE_SIZE); dberr_t err = DB_SUCCESS; byte* src = src_frame; bool page_compressed_encrypted = (mach_read_from_2(tmp+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); - byte* comp_mem = NULL; - byte* uncomp_mem = NULL; + byte uncomp_mem[UNIV_PAGE_SIZE_MAX]; + byte tmp_mem[UNIV_PAGE_SIZE_MAX]; ulint size = (zip_size) ? zip_size : UNIV_PAGE_SIZE; if (page_compressed_encrypted) { - comp_mem = (byte *)malloc(UNIV_PAGE_SIZE); - uncomp_mem = (byte *)malloc(UNIV_PAGE_SIZE); - memcpy(comp_mem, src_frame, UNIV_PAGE_SIZE); - fil_decompress_page(uncomp_mem, comp_mem, - srv_page_size, NULL); - src = uncomp_mem; + memcpy(uncomp_mem, src, srv_page_size); + ulint unzipped1 = fil_page_decompress( + tmp_mem, uncomp_mem); + ut_ad(unzipped1); + if (unzipped1 != srv_page_size) { + src = uncomp_mem; + } } - bool corrupted1 = buf_page_is_corrupted(true, src, zip_size, space); - bool ok = fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err); + ut_ad(!buf_page_is_corrupted(true, src, zip_size, space)); + ut_ad(fil_space_decrypt(crypt_data, tmp_mem, size, tmp, &err)); + ut_ad(err == DB_SUCCESS); /* Need to decompress the page if it was also compressed */ if (page_compressed_encrypted) { - memcpy(comp_mem, tmp_mem, UNIV_PAGE_SIZE); - fil_decompress_page(tmp_mem, comp_mem, - srv_page_size, NULL); - } - - bool corrupted = buf_page_is_corrupted(true, tmp_mem, zip_size, space); - memcpy(tmp_mem+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, src+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8); - bool different = memcmp(src, tmp_mem, size); - - if (!ok || corrupted || corrupted1 || err != DB_SUCCESS || different) { - fprintf(stderr, "ok %d corrupted %d corrupted1 %d err %d different %d\n", - ok , corrupted, corrupted1, err, different); - fprintf(stderr, "src_frame\n"); - buf_page_print(src_frame, zip_size); - fprintf(stderr, "encrypted_frame\n"); - buf_page_print(tmp, zip_size); - fprintf(stderr, "decrypted_frame\n"); - buf_page_print(tmp_mem, zip_size); - ut_ad(0); - } - - free(tmp_mem); - - if (comp_mem) { - free(comp_mem); + byte buf[UNIV_PAGE_SIZE_MAX]; + memcpy(buf, tmp_mem, srv_page_size); + ulint unzipped2 = fil_page_decompress(tmp_mem, buf); + ut_ad(unzipped2); } - if (uncomp_mem) { - free(uncomp_mem); - } + memcpy(tmp_mem + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, + src + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8); + ut_ad(!memcmp(src, tmp_mem, size)); } - #endif /* UNIV_DEBUG */ return tmp; @@ -963,17 +943,17 @@ fil_crypt_get_key_state( /*********************************************************************** Check if a key needs rotation given a key_state -@param[in] encrypt_mode Encryption mode +@param[in] crypt_data Encryption information @param[in] key_version Current key version @param[in] latest_key_version Latest key version @param[in] rotate_key_age when to rotate @return true if key needs rotation, false if not */ static bool fil_crypt_needs_rotation( - fil_encryption_t encrypt_mode, - uint key_version, - uint latest_key_version, - uint rotate_key_age) + const fil_space_crypt_t* crypt_data, + uint key_version, + uint latest_key_version, + uint rotate_key_age) { if (key_version == ENCRYPTION_KEY_VERSION_INVALID) { return false; @@ -986,13 +966,20 @@ fil_crypt_needs_rotation( } if (latest_key_version == 0 && key_version != 0) { - if (encrypt_mode == FIL_ENCRYPTION_DEFAULT) { + if (crypt_data->encryption == FIL_ENCRYPTION_DEFAULT) { /* this is rotation encrypted => unencrypted */ return true; } return false; } + if (crypt_data->encryption == FIL_ENCRYPTION_DEFAULT + && crypt_data->type == CRYPT_SCHEME_1 + && srv_encrypt_tables == 0 ) { + /* This is rotation encrypted => unencrypted */ + return true; + } + /* this is rotation encrypted => encrypted, * only reencrypt if key is sufficiently old */ if (key_version + rotate_key_age < latest_key_version) { @@ -1008,10 +995,17 @@ static inline void fil_crypt_read_crypt_data(fil_space_t* space) { - if (space->crypt_data || space->size) { + if (space->crypt_data || space->size + || !fil_space_get_size(space->id)) { /* The encryption metadata has already been read, or the tablespace is not encrypted and the file has been - opened already. */ + opened already, or the file cannot be accessed, + likely due to a concurrent TRUNCATE or + RENAME or DROP (possibly as part of ALTER TABLE). + FIXME: The file can become unaccessible any time + after this check! We should really remove this + function and instead make crypt_data an integral + part of fil_space_t. */ return; } @@ -1272,9 +1266,10 @@ fil_crypt_space_needs_rotation( } bool need_key_rotation = fil_crypt_needs_rotation( - crypt_data->encryption, + crypt_data, crypt_data->min_key_version, - key_state->key_version, key_state->rotate_key_age); + key_state->key_version, + key_state->rotate_key_age); crypt_data->rotate_state.scrubbing.is_active = btr_scrub_start_space(space->id, &state->scrub_data); @@ -1862,9 +1857,10 @@ fil_crypt_rotate_page( ut_ad(kv == 0); ut_ad(page_get_space_id(frame) == 0); } else if (fil_crypt_needs_rotation( - crypt_data->encryption, - kv, key_state->key_version, - key_state->rotate_key_age)) { + crypt_data, + kv, + key_state->key_version, + key_state->rotate_key_age)) { modified = true; @@ -2002,6 +1998,12 @@ fil_crypt_rotate_pages( continue; } + /* If space is marked as stopping, stop rotating + pages. */ + if (state->space->is_stopping()) { + break; + } + fil_crypt_rotate_page(key_state, state); } } @@ -2050,20 +2052,22 @@ fil_crypt_flush_space( crypt_data->type = CRYPT_SCHEME_UNENCRYPTED; } - /* update page 0 */ - mtr_t mtr; - mtr_start(&mtr); + if (!space->is_stopping()) { + /* update page 0 */ + mtr_t mtr; + mtr_start(&mtr); - const uint zip_size = fsp_flags_get_zip_size(state->space->flags); + const uint zip_size = fsp_flags_get_zip_size(state->space->flags); - buf_block_t* block = buf_page_get_gen(space->id, zip_size, 0, + buf_block_t* block = buf_page_get_gen(space->id, zip_size, 0, RW_X_LATCH, NULL, BUF_GET, __FILE__, __LINE__, &mtr); - byte* frame = buf_block_get_frame(block); + byte* frame = buf_block_get_frame(block); - crypt_data->write_page0(frame, &mtr); + crypt_data->write_page0(frame, &mtr); - mtr_commit(&mtr); + mtr_commit(&mtr); + } } /*********************************************************************** diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 96902cd77ec15dc7c024ecf9b206a628cf069c4f..a88350831651fc3ee4e13a1c2231fc1dc71e501f 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -25,8 +25,6 @@ Created 10/25/1995 Heikki Tuuri *******************************************************/ #include "fil0fil.h" -#include "fil0pagecompress.h" -#include "fsp0pagecompress.h" #include "fil0crypt.h" #include @@ -49,12 +47,10 @@ Created 10/25/1995 Heikki Tuuri #include "page0zip.h" #include "trx0sys.h" #include "row0mysql.h" -#include "os0file.h" #ifndef UNIV_HOTBACKUP # include "buf0lru.h" # include "ibuf0ibuf.h" # include "sync0sync.h" -# include "os0sync.h" #else /* !UNIV_HOTBACKUP */ # include "srv0srv.h" static ulint srv_data_read, srv_data_written; @@ -355,19 +351,6 @@ fil_space_get_by_id( return(space); } -/****************************************************************//** -Get space id from fil node */ -ulint -fil_node_get_space_id( -/*==================*/ - fil_node_t* node) /*!< in: Compressed node*/ -{ - ut_ad(node); - ut_ad(node->space); - - return (node->space->id); -} - /*******************************************************************//** Returns the table space by a given name, NULL if not found. */ fil_space_t* @@ -704,7 +687,7 @@ fil_node_open_file( space->size += node->size; } - ulint atomic_writes = fsp_flags_get_atomic_writes(space->flags); + ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(space->flags); /* printf("Opening file %s\n", node->name); */ @@ -1102,7 +1085,6 @@ fil_mutex_enter_and_prepare_for_io( { fil_space_t* space; ulint count = 0; - ulint count2 = 0; retry: mutex_enter(&fil_system->mutex); @@ -1118,47 +1100,6 @@ fil_mutex_enter_and_prepare_for_io( return; } - if (space->stop_ios) { - ut_ad(space->id != 0); - /* We are going to do a rename file and want to stop new i/o's - for a while */ - - if (count2 > 20000) { - fputs("InnoDB: Warning: tablespace ", stderr); - ut_print_filename(stderr, space->name); - fprintf(stderr, - " has i/o ops stopped for a long time %lu\n", - (ulong) count2); - } - - mutex_exit(&fil_system->mutex); - -#ifndef UNIV_HOTBACKUP - - /* Wake the i/o-handler threads to make sure pending - i/o's are performed */ - os_aio_simulated_wake_handler_threads(); - - /* The sleep here is just to give IO helper threads a - bit of time to do some work. It is not required that - all IO related to the tablespace being renamed must - be flushed here as we do fil_flush() in - fil_rename_tablespace() as well. */ - os_thread_sleep(20000); - -#endif /* UNIV_HOTBACKUP */ - - /* Flush tablespaces so that we can close modified - files in the LRU list */ - fil_flush_file_spaces(FIL_TABLESPACE); - - os_thread_sleep(20000); - - count2++; - - goto retry; - } - fil_node_t* node = UT_LIST_GET_LAST(space->chain); ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain)); @@ -2940,7 +2881,7 @@ fil_delete_tablespace(ulint id, bool drop_ahi) To deal with potential read requests by checking the ::stop_new_ops flag in fil_io() */ - buf_LRU_flush_or_remove_pages(id, NULL, drop_ahi); + buf_LRU_flush_or_remove_pages(id, NULL); #endif /* !UNIV_HOTBACKUP */ @@ -3051,7 +2992,7 @@ fil_discard_tablespace( { dberr_t err; - switch (err = fil_delete_tablespace(id, true)) { + switch (err = fil_delete_tablespace(id)) { case DB_SUCCESS: break; @@ -3253,7 +3194,6 @@ fil_rename_tablespace( ibool success; fil_space_t* space; fil_node_t* node; - ulint count = 0; char* new_path; char* old_name; char* old_path; @@ -3261,25 +3201,10 @@ fil_rename_tablespace( ut_a(id != 0); -retry: - count++; - - if (!(count % 1000)) { - ut_print_timestamp(stderr); - fputs(" InnoDB: Warning: problems renaming ", stderr); - ut_print_filename(stderr, - old_name_in ? old_name_in : not_given); - fputs(" to ", stderr); - ut_print_filename(stderr, new_name); - fprintf(stderr, ", %lu iterations\n", (ulong) count); - } - mutex_enter(&fil_system->mutex); space = fil_space_get_by_id(id); - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; ); - if (space == NULL) { ib_logf(IB_LOG_LEVEL_ERROR, "Cannot find space id %lu in the tablespace " @@ -3291,54 +3216,11 @@ fil_rename_tablespace( return(FALSE); } - if (count > 25000) { - space->stop_ios = FALSE; - mutex_exit(&fil_system->mutex); - - return(FALSE); - } - - /* We temporarily close the .ibd file because we do not trust that - operating systems can rename an open file. For the closing we have to - wait until there are no pending i/o's or flushes on the file. */ - - space->stop_ios = TRUE; - /* The following code must change when InnoDB supports multiple datafiles per tablespace. */ ut_a(UT_LIST_GET_LEN(space->chain) == 1); node = UT_LIST_GET_FIRST(space->chain); - if (node->n_pending > 0 - || node->n_pending_flushes > 0 - || node->being_extended) { - /* There are pending i/o's or flushes or the file is - currently being extended, sleep for a while and - retry */ - - mutex_exit(&fil_system->mutex); - - os_thread_sleep(20000); - - goto retry; - - } else if (node->modification_counter > node->flush_counter) { - /* Flush the space */ - - mutex_exit(&fil_system->mutex); - - os_thread_sleep(20000); - - fil_flush(id); - - goto retry; - - } else if (node->open) { - /* Close the file */ - - fil_node_close_file(node, fil_system); - } - /* Check that the old name in the space is right */ if (old_name_in) { @@ -3357,17 +3239,9 @@ fil_rename_tablespace( space, node, new_name, new_path); if (success) { - - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", - goto skip_second_rename; ); - success = os_file_rename( innodb_file_data_key, old_path, new_path); - DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2", -skip_second_rename: - success = FALSE; ); - if (!success) { /* We have to revert the changes we made to the tablespace memory cache */ @@ -3377,8 +3251,6 @@ fil_rename_tablespace( } } - space->stop_ios = FALSE; - mutex_exit(&fil_system->mutex); #ifndef UNIV_HOTBACKUP @@ -4110,7 +3982,6 @@ fil_open_single_table_tablespace( fsp_open_info remote; ulint tablespaces_found = 0; ulint valid_tablespaces_found = 0; - ulint atomic_writes = 0; fil_space_crypt_t* crypt_data = NULL; #ifdef UNIV_SYNC_DEBUG @@ -4125,7 +3996,7 @@ fil_open_single_table_tablespace( } ut_ad(fsp_flags_is_valid(flags & ~FSP_FLAGS_MEM_MASK, id)); - atomic_writes = fsp_flags_get_atomic_writes(flags); + const ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(flags); memset(&def, 0, sizeof(def)); memset(&dict, 0, sizeof(dict)); @@ -4468,17 +4339,7 @@ fil_open_single_table_tablespace( mem_free(def.filepath); - /* We need to check fsp flags when no errors has happened and - server was not started on read only mode and tablespace validation - was requested or flags contain other table options except - low order bits to FSP_FLAGS_POS_PAGE_SSIZE position. - Note that flag comparison is pessimistic. Adjust is required - only when flags contain buggy MariaDB 10.1.0 - - MariaDB 10.1.20 flags. */ - if (err == DB_SUCCESS - && !srv_read_only_mode - && (validate - || flags >= (1U << FSP_FLAGS_POS_PAGE_SSIZE))) { + if (err == DB_SUCCESS && validate && !srv_read_only_mode) { fsp_flags_try_adjust(id, flags & ~FSP_FLAGS_MEM_MASK); } @@ -6161,7 +6022,8 @@ fil_io( } else if (type == OS_FILE_WRITE) { ut_ad(!srv_read_only_mode); srv_stats.data_written.add(len); - if (fil_page_is_index_page((byte *)buf)) { + if (mach_read_from_2(static_cast(buf) + + FIL_PAGE_TYPE) == FIL_PAGE_INDEX) { srv_stats.index_pages_written.inc(); } else { srv_stats.non_index_pages_written.inc(); @@ -6693,479 +6555,6 @@ fil_close(void) fil_system = NULL; } -/********************************************************************//** -Initializes a buffer control block when the buf_pool is created. */ -static -void -fil_buf_block_init( -/*===============*/ - buf_block_t* block, /*!< in: pointer to control block */ - byte* frame) /*!< in: pointer to buffer frame */ -{ - UNIV_MEM_DESC(frame, UNIV_PAGE_SIZE); - - block->frame = frame; - - block->page.io_fix = BUF_IO_NONE; - /* There are assertions that check for this. */ - block->page.buf_fix_count = 1; - block->page.state = BUF_BLOCK_READY_FOR_USE; - - page_zip_des_init(&block->page.zip); -} - -struct fil_iterator_t { - pfs_os_file_t file; /*!< File handle */ - const char* filepath; /*!< File path name */ - os_offset_t start; /*!< From where to start */ - os_offset_t end; /*!< Where to stop */ - os_offset_t file_size; /*!< File size in bytes */ - ulint page_size; /*!< Page size */ - ulint n_io_buffers; /*!< Number of pages to use - for IO */ - byte* io_buffer; /*!< Buffer to use for IO */ - fil_space_crypt_t *crypt_data; /*!< Crypt data (if encrypted) */ - byte* crypt_io_buffer; /*!< IO buffer when encrypted */ -}; - -/********************************************************************//** -TODO: This can be made parallel trivially by chunking up the file and creating -a callback per thread. . Main benefit will be to use multiple CPUs for -checksums and compressed tables. We have to do compressed tables block by -block right now. Secondly we need to decompress/compress and copy too much -of data. These are CPU intensive. - -Iterate over all the pages in the tablespace. -@param iter - Tablespace iterator -@param block - block to use for IO -@param callback - Callback to inspect and update page contents -@retval DB_SUCCESS or error code */ -static -dberr_t -fil_iterate( -/*========*/ - const fil_iterator_t& iter, - buf_block_t* block, - PageCallback& callback) -{ - os_offset_t offset; - ulint page_no = 0; - ulint space_id = callback.get_space_id(); - ulint n_bytes = iter.n_io_buffers * iter.page_size; - - ut_ad(!srv_read_only_mode); - - /* TODO: For compressed tables we do a lot of useless - copying for non-index pages. Unfortunately, it is - required by buf_zip_decompress() */ - const bool row_compressed = callback.get_zip_size() > 0; - - for (offset = iter.start; offset < iter.end; offset += n_bytes) { - - byte* io_buffer = iter.io_buffer; - - block->frame = io_buffer; - - if (row_compressed) { - page_zip_des_init(&block->page.zip); - page_zip_set_size(&block->page.zip, iter.page_size); - block->page.zip.data = block->frame + UNIV_PAGE_SIZE; - ut_d(block->page.zip.m_external = true); - ut_ad(iter.page_size == callback.get_zip_size()); - - /* Zip IO is done in the compressed page buffer. */ - io_buffer = block->page.zip.data; - } - - /* We have to read the exact number of bytes. Otherwise the - InnoDB IO functions croak on failed reads. */ - - n_bytes = static_cast( - ut_min(static_cast(n_bytes), - iter.end - offset)); - - ut_ad(n_bytes > 0); - ut_ad(!(n_bytes % iter.page_size)); - - const bool encrypted = iter.crypt_data != NULL - && iter.crypt_data->should_encrypt(); - /* Use additional crypt io buffer if tablespace is encrypted */ - byte* const readptr = encrypted - ? iter.crypt_io_buffer : io_buffer; - byte* const writeptr = readptr; - - if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) { - - ib_logf(IB_LOG_LEVEL_ERROR, "os_file_read() failed"); - - return(DB_IO_ERROR); - } - - bool updated = false; - os_offset_t page_off = offset; - ulint n_pages_read = (ulint) n_bytes / iter.page_size; - bool decrypted = false; - - for (ulint i = 0; i < n_pages_read; ++i) { - ulint size = iter.page_size; - dberr_t err = DB_SUCCESS; - byte* src = readptr + (i * size); - byte* dst = io_buffer + (i * size); - bool frame_changed = false; - - ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); - - const bool page_compressed - = page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED - || page_type == FIL_PAGE_PAGE_COMPRESSED; - - /* If tablespace is encrypted, we need to decrypt - the page. Note that tablespaces are not in - fil_system during import. */ - if (encrypted) { - decrypted = fil_space_decrypt( - iter.crypt_data, - dst, //dst - iter.page_size, - src, // src - &err); // src - - if (err != DB_SUCCESS) { - return(err); - } - - if (decrypted) { - updated = true; - } else { - if (!page_compressed && !row_compressed) { - block->frame = src; - frame_changed = true; - } else { - memcpy(dst, src, size); - } - } - } - - /* If the original page is page_compressed, we need - to decompress page before we can update it. */ - if (page_compressed) { - fil_decompress_page(NULL, dst, ulong(size), - NULL); - updated = true; - } - - buf_block_set_file_page(block, space_id, page_no++); - - if ((err = callback(page_off, block)) != DB_SUCCESS) { - - return(err); - - } else if (!updated) { - updated = buf_block_get_state(block) - == BUF_BLOCK_FILE_PAGE; - } - - buf_block_set_state(block, BUF_BLOCK_NOT_USED); - buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); - - /* If tablespace is encrypted we use additional - temporary scratch area where pages are read - for decrypting readptr == crypt_io_buffer != io_buffer. - - Destination for decryption is a buffer pool block - block->frame == dst == io_buffer that is updated. - Pages that did not require decryption even when - tablespace is marked as encrypted are not copied - instead block->frame is set to src == readptr. - - For encryption we again use temporary scratch area - writeptr != io_buffer == dst - that is then written to the tablespace - - (1) For normal tables io_buffer == dst == writeptr - (2) For only page compressed tables - io_buffer == dst == writeptr - (3) For encrypted (and page compressed) - readptr != io_buffer == dst != writeptr - */ - - ut_ad(!encrypted && !page_compressed ? - src == dst && dst == writeptr + (i * size):1); - ut_ad(page_compressed && !encrypted ? - src == dst && dst == writeptr + (i * size):1); - ut_ad(encrypted ? - src != dst && dst != writeptr + (i * size):1); - - if (encrypted) { - memcpy(writeptr + (i * size), - row_compressed ? block->page.zip.data : - block->frame, size); - } - - if (frame_changed) { - block->frame = dst; - } - - src = io_buffer + (i * size); - - if (page_compressed) { - ulint len = 0; - - fil_compress_page( - NULL, - src, - NULL, - size, - 0,/* FIXME: compression level */ - 512,/* FIXME: use proper block size */ - encrypted, - &len); - - updated = true; - } - - /* If tablespace is encrypted, encrypt page before we - write it back. Note that we should not encrypt the - buffer that is in buffer pool. */ - /* NOTE: At this stage of IMPORT the - buffer pool is not being used at all! */ - if (decrypted && encrypted) { - byte *dest = writeptr + (i * size); - ulint space = mach_read_from_4( - src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - ulint offset = mach_read_from_4(src + FIL_PAGE_OFFSET); - ib_uint64_t lsn = mach_read_from_8(src + FIL_PAGE_LSN); - - byte* tmp = fil_encrypt_buf( - iter.crypt_data, - space, - offset, - lsn, - src, - iter.page_size == UNIV_PAGE_SIZE ? 0 : iter.page_size, - dest); - - if (tmp == src) { - /* TODO: remove unnecessary memcpy's */ - memcpy(dest, src, size); - } - - updated = true; - } - - page_off += iter.page_size; - block->frame += iter.page_size; - } - - /* A page was updated in the set, write back to disk. */ - if (updated - && !os_file_write( - iter.filepath, iter.file, writeptr, - offset, (ulint) n_bytes)) { - - ib_logf(IB_LOG_LEVEL_ERROR, "os_file_write() failed"); - - return(DB_IO_ERROR); - } - } - - return(DB_SUCCESS); -} - -/********************************************************************//** -Iterate over all the pages in the tablespace. -@param table - the table definiton in the server -@param n_io_buffers - number of blocks to read and write together -@param callback - functor that will do the page updates -@return DB_SUCCESS or error code */ -UNIV_INTERN -dberr_t -fil_tablespace_iterate( -/*===================*/ - dict_table_t* table, - ulint n_io_buffers, - PageCallback& callback) -{ - dberr_t err; - pfs_os_file_t file; - char* filepath; - - ut_a(n_io_buffers > 0); - ut_ad(!srv_read_only_mode); - - DBUG_EXECUTE_IF("ib_import_trigger_corruption_1", - return(DB_CORRUPTION);); - - if (DICT_TF_HAS_DATA_DIR(table->flags)) { - dict_get_and_save_data_dir_path(table, false); - ut_a(table->data_dir_path); - - filepath = os_file_make_remote_pathname( - table->data_dir_path, table->name, "ibd"); - } else { - filepath = fil_make_ibd_name(table->name, false); - } - - { - ibool success; - - file = os_file_create_simple_no_error_handling( - innodb_file_data_key, filepath, - OS_FILE_OPEN, OS_FILE_READ_WRITE, &success, FALSE); - - DBUG_EXECUTE_IF("fil_tablespace_iterate_failure", - { - static bool once; - - if (!once || ut_rnd_interval(0, 10) == 5) { - once = true; - success = FALSE; - os_file_close(file); - } - }); - - if (!success) { - /* The following call prints an error message */ - os_file_get_last_error(true); - - ib_logf(IB_LOG_LEVEL_ERROR, - "Trying to import a tablespace, but could not " - "open the tablespace file %s", filepath); - - mem_free(filepath); - - return(DB_TABLESPACE_NOT_FOUND); - - } else { - err = DB_SUCCESS; - } - } - - callback.set_file(filepath, file); - - os_offset_t file_size = os_file_get_size(file); - ut_a(file_size != (os_offset_t) -1); - - /* The block we will use for every physical page */ - buf_block_t block; - - memset(&block, 0x0, sizeof(block)); - - /* Allocate a page to read in the tablespace header, so that we - can determine the page size and zip_size (if it is compressed). - We allocate an extra page in case it is a compressed table. One - page is to ensure alignement. */ - - void* page_ptr = mem_alloc(3 * UNIV_PAGE_SIZE); - byte* page = static_cast(ut_align(page_ptr, UNIV_PAGE_SIZE)); - - fil_buf_block_init(&block, page); - - /* Read the first page and determine the page and zip size. */ - - if (!os_file_read(file, page, 0, UNIV_PAGE_SIZE)) { - - err = DB_IO_ERROR; - - } else if ((err = callback.init(file_size, &block)) == DB_SUCCESS) { - fil_iterator_t iter; - - iter.file = file; - iter.start = 0; - iter.end = file_size; - iter.filepath = filepath; - iter.file_size = file_size; - iter.n_io_buffers = n_io_buffers; - iter.page_size = callback.get_page_size(); - - /* In MariaDB/MySQL 5.6 tablespace does not exist - during import, therefore we can't use space directly - here. */ - ulint crypt_data_offset = fsp_header_get_crypt_offset( - callback.get_zip_size()); - - /* read (optional) crypt data */ - iter.crypt_data = fil_space_read_crypt_data( - 0, page, crypt_data_offset); - - /* Compressed pages can't be optimised for block IO for now. - We do the IMPORT page by page. */ - - if (callback.get_zip_size() > 0) { - iter.n_io_buffers = 1; - ut_a(iter.page_size == callback.get_zip_size()); - } - - /** If tablespace is encrypted, it needs extra buffers */ - if (iter.crypt_data != NULL) { - /* decrease io buffers so that memory - * consumption doesnt double - * note: the +1 is to avoid n_io_buffers getting down to 0 */ - iter.n_io_buffers = (iter.n_io_buffers + 1) / 2; - } - - /** Add an extra page for compressed page scratch area. */ - - void* io_buffer = mem_alloc( - (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); - - iter.io_buffer = static_cast( - ut_align(io_buffer, UNIV_PAGE_SIZE)); - - void* crypt_io_buffer = NULL; - if (iter.crypt_data != NULL) { - crypt_io_buffer = mem_alloc( - (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); - iter.crypt_io_buffer = static_cast( - ut_align(crypt_io_buffer, UNIV_PAGE_SIZE)); - } - - err = fil_iterate(iter, &block, callback); - - mem_free(io_buffer); - - if (crypt_io_buffer != NULL) { - mem_free(crypt_io_buffer); - iter.crypt_io_buffer = NULL; - fil_space_destroy_crypt_data(&iter.crypt_data); - } - } - - if (err == DB_SUCCESS) { - - ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk"); - - if (!os_file_flush(file)) { - ib_logf(IB_LOG_LEVEL_INFO, "os_file_flush() failed!"); - err = DB_IO_ERROR; - } else { - ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk - done!"); - } - } - - os_file_close(file); - - mem_free(page_ptr); - mem_free(filepath); - - return(err); -} - -/** -Set the tablespace compressed table size. -@return DB_SUCCESS if it is valie or DB_CORRUPTION if not */ -dberr_t -PageCallback::set_zip_size(const buf_frame_t* page) UNIV_NOTHROW -{ - m_zip_size = fsp_header_get_zip_size(page); - - if (!ut_is_2pow(m_zip_size) || m_zip_size > UNIV_ZIP_SIZE_MAX) { - return(DB_CORRUPTION); - } - - return(DB_SUCCESS); -} - /********************************************************************//** Delete the tablespace file and any related files like .cfg. This should not be called for temporary tables. */ diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index edc932f36f5f193d990e255fa1bb9e6639e6aeab..25cd8e28a91dd35006f703dc6d57d28cdbe752f4 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017, MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018, 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 @@ -80,73 +80,26 @@ static ulint srv_data_read, srv_data_written; #include "snappy-c.h" #endif -/* Used for debugging */ -//#define UNIV_PAGECOMPRESS_DEBUG 1 - -/****************************************************************//** -For page compressed pages compress the page before actual write -operation. -@return compressed page to be written*/ -UNIV_INTERN -byte* -fil_compress_page( -/*==============*/ - fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ - byte* buf, /*!< in: buffer from which to write; in aio - this must be appropriately aligned */ - byte* out_buf, /*!< out: compressed buffer */ - ulint len, /*!< in: length of input buffer.*/ - ulint level, /* in: compression level */ - ulint block_size, /*!< in: block size */ - bool encrypted, /*!< in: is page also encrypted */ - ulint* out_len) /*!< out: actual length of compressed - page */ +/** Compress a page_compressed page before writing to a data file. +@param[in] buf page to be compressed +@param[out] out_buf compressed page +@param[in] level compression level +@param[in] block_size file system block size +@param[in] encrypted whether the page will be subsequently encrypted +@return actual length of compressed page +@retval 0 if the page was not compressed */ +UNIV_INTERN ulint fil_page_compress(const byte* buf, byte* out_buf, ulint level, + ulint block_size, bool encrypted) { - int err = Z_OK; - int comp_level = level; + int comp_level = int(level); ulint header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; - ulint write_size = 0; -#if HAVE_LZO - lzo_uint write_size_lzo = write_size; -#endif /* Cache to avoid change during function execution */ ulint comp_method = innodb_compression_algorithm; - bool allocated = false; - - /* page_compression does not apply to tables or tablespaces - that use ROW_FORMAT=COMPRESSED */ - ut_ad(!space || !FSP_FLAGS_GET_ZIP_SSIZE(space->flags)); if (encrypted) { header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; } - if (!out_buf) { - allocated = true; - ulint size = UNIV_PAGE_SIZE; - - /* Both snappy and lzo compression methods require that - output buffer used for compression is bigger than input - buffer. Increase the allocated buffer size accordingly. */ -#if HAVE_SNAPPY - if (comp_method == PAGE_SNAPPY_ALGORITHM) { - size = snappy_max_compressed_length(size); - } -#endif -#if HAVE_LZO - if (comp_method == PAGE_LZO_ALGORITHM) { - size += LZO1X_1_15_MEM_COMPRESS; - } -#endif - - out_buf = static_cast(ut_malloc(size)); - } - - ut_ad(buf); - ut_ad(out_buf); - ut_ad(len); - ut_ad(out_len); - /* Let's not compress file space header or extent descriptor */ switch (fil_page_get_type(buf)) { @@ -154,8 +107,7 @@ fil_compress_page( case FIL_PAGE_TYPE_FSP_HDR: case FIL_PAGE_TYPE_XDES: case FIL_PAGE_PAGE_COMPRESSED: - *out_len = len; - goto err_exit; + return 0; } /* If no compression level was provided to this table, use system @@ -164,204 +116,113 @@ fil_compress_page( comp_level = page_zip_level; } - DBUG_PRINT("compress", - ("Preparing for space " ULINTPF " '%s' len " ULINTPF, - space ? space->id : 0, - space ? space->name : "(import)", - len)); - - write_size = UNIV_PAGE_SIZE - header_len; + ulint write_size = srv_page_size - header_len; - switch(comp_method) { + switch (comp_method) { + default: + ut_ad(!"unknown compression method"); + /* fall through */ + case PAGE_UNCOMPRESSED: + return 0; + case PAGE_ZLIB_ALGORITHM: + { + ulong len = uLong(write_size); + if (Z_OK == compress2( + out_buf + header_len, &len, + buf, uLong(srv_page_size), comp_level)) { + write_size = len; + goto success; + } + } + break; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: - -#ifdef HAVE_LZ4_COMPRESS_DEFAULT - err = LZ4_compress_default((const char *)buf, - (char *)out_buf+header_len, len, write_size); -#else - err = LZ4_compress_limitedOutput((const char *)buf, - (char *)out_buf+header_len, len, write_size); -#endif /* HAVE_LZ4_COMPRESS_DEFAULT */ - write_size = err; - - if (err == 0) { - /* If error we leave the actual page as it was */ - -#ifndef UNIV_PAGECOMPRESS_DEBUG - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; -#endif - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); -#ifndef UNIV_PAGECOMPRESS_DEBUG - } -#endif - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; +# ifdef HAVE_LZ4_COMPRESS_DEFAULT + write_size = LZ4_compress_default( + reinterpret_cast(buf), + reinterpret_cast(out_buf) + header_len, + int(srv_page_size), int(write_size)); +# else + write_size = LZ4_compress_limitedOutput( + reinterpret_cast(buf), + reinterpret_cast(out_buf) + header_len, + int(srv_page_size), int(write_size)); +# endif + + if (write_size) { + goto success; } break; #endif /* HAVE_LZ4 */ #ifdef HAVE_LZO - case PAGE_LZO_ALGORITHM: - err = lzo1x_1_15_compress( - buf, len, out_buf+header_len, &write_size_lzo, out_buf+UNIV_PAGE_SIZE); - - write_size = write_size_lzo; - - if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + case PAGE_LZO_ALGORITHM: { + lzo_uint len = write_size; + + if (LZO_E_OK == lzo1x_1_15_compress( + buf, srv_page_size, + out_buf + header_len, &len, + out_buf + srv_page_size) + && len <= write_size) { + write_size = len; + goto success; } - break; + } #endif /* HAVE_LZO */ #ifdef HAVE_LZMA case PAGE_LZMA_ALGORITHM: { - size_t out_pos=0; - - err = lzma_easy_buffer_encode( - comp_level, - LZMA_CHECK_NONE, - NULL, /* No custom allocator, use malloc/free */ - reinterpret_cast(buf), - len, - reinterpret_cast(out_buf + header_len), - &out_pos, - (size_t)write_size); - - if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, out_pos); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + size_t out_pos = 0; + + if (LZMA_OK == lzma_easy_buffer_encode( + comp_level, LZMA_CHECK_NONE, NULL, + buf, srv_page_size, out_buf + header_len, + &out_pos, write_size) + && out_pos <= write_size) { + write_size = out_pos; + goto success; } - - write_size = out_pos; - break; } #endif /* HAVE_LZMA */ #ifdef HAVE_BZIP2 case PAGE_BZIP2_ALGORITHM: { - - err = BZ2_bzBuffToBuffCompress( - (char *)(out_buf + header_len), - (unsigned int *)&write_size, - (char *)buf, - len, - 1, - 0, - 0); - - if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + unsigned len = unsigned(write_size); + if (BZ_OK == BZ2_bzBuffToBuffCompress( + reinterpret_cast(out_buf + header_len), + &len, + const_cast( + reinterpret_cast(buf)), + unsigned(srv_page_size), 1, 0, 0) + && len <= write_size) { + write_size = len; + goto success; } break; } #endif /* HAVE_BZIP2 */ #ifdef HAVE_SNAPPY - case PAGE_SNAPPY_ALGORITHM: - { - snappy_status cstatus; - write_size = snappy_max_compressed_length(UNIV_PAGE_SIZE); - - cstatus = snappy_compress( - (const char *)buf, - (size_t)len, - (char *)(out_buf+header_len), - (size_t*)&write_size); - - if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " err %d write_size " ULINTPF ".", - space->id, space->name, len, - (int)cstatus, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; + case PAGE_SNAPPY_ALGORITHM: { + size_t len = snappy_max_compressed_length(srv_page_size); + + if (SNAPPY_OK == snappy_compress( + reinterpret_cast(buf), + srv_page_size, + reinterpret_cast(out_buf) + header_len, + &len) + && len <= write_size) { + write_size = len; + goto success; } break; } #endif /* HAVE_SNAPPY */ - - case PAGE_ZLIB_ALGORITHM: - err = compress2(out_buf+header_len, (ulong*)&write_size, buf, - uLong(len), comp_level); - - if (err != Z_OK) { - /* If error we leave the actual page as it was */ - - if (space && !space->printed_compression_failure) { - space->printed_compression_failure = true; - ib_logf(IB_LOG_LEVEL_WARN, - "Compression failed for space " ULINTPF - " name %s len " ULINTPF - " rt %d write_size " ULINTPF ".", - space->id, space->name, len, - err, write_size); - } - - srv_stats.pages_page_compression_error.inc(); - *out_len = len; - goto err_exit; - } - break; - - case PAGE_UNCOMPRESSED: - *out_len = len; - return (buf); - break; - default: - ut_error; - break; } + srv_stats.pages_page_compression_error.inc(); + return 0; +success: /* Set up the page header */ memcpy(out_buf, buf, FIL_PAGE_DATA); /* Set up the checksum */ @@ -392,22 +253,11 @@ fil_compress_page( /* Verify that page can be decompressed */ { - byte *comp_page; - byte *uncomp_page; - - comp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - uncomp_page = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - memcpy(comp_page, out_buf, UNIV_PAGE_SIZE); - - fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); - - if (buf_page_is_corrupted(false, uncomp_page, 0, space)) { - buf_page_print(uncomp_page, 0); - ut_ad(0); - } - - ut_free(comp_page); - ut_free(uncomp_page); + page_t tmp_buf[UNIV_PAGE_SIZE_MAX]; + page_t page[UNIV_PAGE_SIZE_MAX]; + memcpy(page, out_buf, srv_page_size); + ut_ad(fil_page_decompress(tmp_buf, page)); + ut_ad(!buf_page_is_corrupted(false, page, 0, NULL)); } #endif /* UNIV_DEBUG */ @@ -431,324 +281,144 @@ fil_compress_page( #endif } - DBUG_PRINT("compress", - ("Succeeded for space " ULINTPF - " '%s' len " ULINTPF " out_len " ULINTPF, - space ? space->id : 0, - space ? space->name : "(import)", - len, write_size)); - - srv_stats.page_compression_saved.add((len - write_size)); + srv_stats.page_compression_saved.add(srv_page_size - write_size); srv_stats.pages_page_compressed.inc(); /* If we do not persistently trim rest of page, we need to write it all */ if (!srv_use_trim) { - memset(out_buf+write_size,0,len-write_size); - write_size = len; - } - - *out_len = write_size; - - if (allocated) { - /* TODO: reduce number of memcpy's */ - memcpy(buf, out_buf, len); - } else { - return(out_buf); - } - -err_exit: - if (allocated) { - ut_free(out_buf); + memset(out_buf + write_size, 0, srv_page_size - write_size); } - return (buf); - + return write_size; } -/****************************************************************//** -For page compressed pages decompress the page after actual read -operation. */ -UNIV_INTERN -void -fil_decompress_page( -/*================*/ - byte* page_buf, /*!< in: preallocated buffer or NULL */ - byte* buf, /*!< out: buffer from which to read; in aio - this must be appropriately aligned */ - ulong len, /*!< in: length of output buffer.*/ - ulint* write_size, /*!< in/out: Actual payload size of - the compressed data. */ - bool return_error) /*!< in: true if only an error should - be produced when decompression fails. - By default this parameter is false. */ +/** Decompress a page that may be subject to page_compressed compression. +@param[in,out] tmp_buf temporary buffer (of innodb_page_size) +@param[in,out] buf possibly compressed page buffer +@return size of the compressed data +@retval 0 if decompression failed +@retval srv_page_size if the page was not compressed */ +UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) { - int err = 0; - ulint actual_size = 0; - ulint compression_alg = 0; - byte *in_buf; - ulint ptype; - ulint header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; - - ut_ad(buf); - ut_ad(len); - - ptype = mach_read_from_2(buf+FIL_PAGE_TYPE); - - if (ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { - header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; - } - - /* Do not try to uncompressed pages that are not compressed */ - if (ptype != FIL_PAGE_PAGE_COMPRESSED && - ptype != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED && - ptype != FIL_PAGE_TYPE_COMPRESSED) { - return; - } - - // If no buffer was given, we need to allocate temporal buffer - if (page_buf == NULL) { - in_buf = static_cast(ut_malloc(UNIV_PAGE_SIZE)); - memset(in_buf, 0, UNIV_PAGE_SIZE); - } else { - in_buf = page_buf; + const unsigned ptype = mach_read_from_2(buf+FIL_PAGE_TYPE); + ulint header_len; + ib_uint64_t compression_alg; + switch (ptype) { + case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED: + header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE + + FIL_PAGE_COMPRESSION_METHOD_SIZE; + compression_alg = mach_read_from_2( + FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE + buf); + break; + case FIL_PAGE_PAGE_COMPRESSED: + header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; + compression_alg = mach_read_from_8( + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + buf); + break; + default: + return srv_page_size; } - /* Before actual decompress, make sure that page type is correct */ - - if (mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM) != BUF_NO_CHECKSUM_MAGIC || - (ptype != FIL_PAGE_PAGE_COMPRESSED && - ptype != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: We try to uncompress corrupted page" - " CRC " ULINTPF " type " ULINTPF " len " ULINTPF ".", - mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM), - mach_read_from_2(buf+FIL_PAGE_TYPE), len); - - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; + if (mach_read_from_4(buf + FIL_PAGE_SPACE_OR_CHKSUM) + != BUF_NO_CHECKSUM_MAGIC) { + return 0; } - /* Get compression algorithm */ - if (ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { - compression_alg = mach_read_from_2(buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE); - } else { - compression_alg = mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - } + ulint actual_size = mach_read_from_2(buf + FIL_PAGE_DATA); - /* Get the actual size of compressed page */ - actual_size = mach_read_from_2(buf+FIL_PAGE_DATA); /* Check if payload size is corrupted */ - if (actual_size == 0 || actual_size > UNIV_PAGE_SIZE) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: We try to uncompress corrupted page" - " actual size " ULINTPF " compression %s.", - actual_size, fil_get_compression_alg_name(compression_alg)); - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; + if (actual_size == 0 || actual_size > srv_page_size - header_len) { + return 0; } - /* Store actual payload size of the compressed data. This pointer - points to buffer pool. */ - if (write_size) { - *write_size = actual_size; - } - - DBUG_PRINT("compress", - ("Preparing for decompress for len " ULINTPF ".", - actual_size)); - - switch(compression_alg) { + switch (compression_alg) { + default: + ib_logf(IB_LOG_LEVEL_ERROR, + "Unknown compression algorithm " UINT64PF, + compression_alg); + return 0; case PAGE_ZLIB_ALGORITHM: - err= uncompress(in_buf, &len, buf+header_len, (unsigned long)actual_size); - - /* If uncompress fails it means that page is corrupted */ - if (err != Z_OK) { - - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; + { + uLong len = srv_page_size; + if (Z_OK != uncompress(tmp_buf, &len, + buf + header_len, + uLong(actual_size)) + && len != srv_page_size) { + return 0; } - ut_error; } break; - #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: - err = LZ4_decompress_fast((const char *)buf+header_len, (char *)in_buf, len); - - if (err != (int)actual_size) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + if (LZ4_decompress_safe(reinterpret_cast(buf) + + header_len, + reinterpret_cast(tmp_buf), + actual_size, srv_page_size) + == int(srv_page_size)) { + break; } - break; + return 0; #endif /* HAVE_LZ4 */ #ifdef HAVE_LZO case PAGE_LZO_ALGORITHM: { - ulint olen = 0; - lzo_uint olen_lzo = olen; - err = lzo1x_decompress((const unsigned char *)buf+header_len, - actual_size,(unsigned char *)in_buf, &olen_lzo, NULL); - - olen = olen_lzo; - - if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but uncompress failed with error %d " - " size " ULINTPF " len " ULINTPF ".", - err, actual_size, len); - - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + lzo_uint len_lzo = srv_page_size; + if (LZO_E_OK == lzo1x_decompress_safe( + buf + header_len, + actual_size, tmp_buf, &len_lzo, NULL) + && len_lzo == srv_page_size) { + break; } - break; + return 0; } #endif /* HAVE_LZO */ #ifdef HAVE_LZMA case PAGE_LZMA_ALGORITHM: { - - lzma_ret ret; size_t src_pos = 0; size_t dst_pos = 0; uint64_t memlimit = UINT64_MAX; - ret = lzma_stream_buffer_decode( - &memlimit, - 0, - NULL, - buf+header_len, - &src_pos, - actual_size, - in_buf, - &dst_pos, - len); - - - if (ret != LZMA_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only %ld bytes" - " size " ULINTPF "len " ULINTPF ".", - dst_pos, actual_size, len); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + if (LZMA_OK == lzma_stream_buffer_decode( + &memlimit, 0, NULL, buf + header_len, + &src_pos, actual_size, tmp_buf, &dst_pos, + srv_page_size) + && dst_pos == srv_page_size) { + break; } - - break; + return 0; } #endif /* HAVE_LZMA */ #ifdef HAVE_BZIP2 case PAGE_BZIP2_ALGORITHM: { - unsigned int dst_pos = UNIV_PAGE_SIZE; - - err = BZ2_bzBuffToBuffDecompress( - (char *)in_buf, - &dst_pos, - (char *)(buf+header_len), - actual_size, - 1, - 0); - - if (err != BZ_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only %du bytes" - " size " ULINTPF " len " ULINTPF " err %d.", - dst_pos, actual_size, len, err); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + unsigned int dst_pos = srv_page_size; + if (BZ_OK == BZ2_bzBuffToBuffDecompress( + reinterpret_cast(tmp_buf), + &dst_pos, + reinterpret_cast(buf) + header_len, + actual_size, 1, 0) + && dst_pos == srv_page_size) { + break; } - break; + return 0; } #endif /* HAVE_BZIP2 */ #ifdef HAVE_SNAPPY - case PAGE_SNAPPY_ALGORITHM: - { - snappy_status cstatus; - ulint olen = UNIV_PAGE_SIZE; - - cstatus = snappy_uncompress( - (const char *)(buf+header_len), - (size_t)actual_size, - (char *)in_buf, - (size_t*)&olen); - - if (cstatus != SNAPPY_OK || olen != UNIV_PAGE_SIZE) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but decompression read only " ULINTPF " bytes" - " size " ULINTPF " len " ULINTPF " err %d.", - olen, actual_size, len, (int)cstatus); - fflush(stderr); - - if (return_error) { - goto error_return; - } - ut_error; + case PAGE_SNAPPY_ALGORITHM: { + size_t olen = srv_page_size; + + if (SNAPPY_OK == snappy_uncompress( + reinterpret_cast(buf) + header_len, + actual_size, + reinterpret_cast(tmp_buf), &olen) + && olen == srv_page_size) { + break; } - - break; + return 0; } #endif /* HAVE_SNAPPY */ - default: - ib_logf(IB_LOG_LEVEL_ERROR, - "Corruption: Page is marked as compressed" - " but compression algorithm %s" - " is not known." - ,fil_get_compression_alg_name(compression_alg)); - - fflush(stderr); - if (return_error) { - goto error_return; - } - ut_error; - break; } srv_stats.pages_page_decompressed.inc(); - - /* Copy the uncompressed page to the buffer pool, not - really any other options. */ - memcpy(buf, in_buf, len); - -error_return: - if (page_buf != in_buf) { - ut_free(in_buf); - } + memcpy(buf, tmp_buf, srv_page_size); + return actual_size; } diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index ffed8a6edd342a6fc417cabfd569a427c179501d..f97e0c1331b74e1fc49b26d1beea4deb2014ee06 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -3035,7 +3035,7 @@ fseg_free_page_low( /* Drop search system page hash index if the page is found in the pool and is hashed */ - btr_search_drop_page_hash_when_freed(space, zip_size, page); + btr_search_drop_page_hash_when_freed(space, page); descr = xdes_get_descriptor(space, zip_size, page, mtr); @@ -3261,7 +3261,7 @@ fseg_free_extent( found in the pool and is hashed */ btr_search_drop_page_hash_when_freed( - space, zip_size, first_page_in_extent + i); + space, first_page_in_extent + i); } } diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 98aaf610f2a9a9d4ef6228c7944435df6258d468..42cb2056dfc20c755ba8a64a90be195ae3159fcc 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, 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 @@ -4627,6 +4627,7 @@ fts_sync( ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped + || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } @@ -4637,17 +4638,6 @@ fts_sync( end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); - if (error == DB_SUCCESS) { - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing) { - index_cache->index->index_fts_syncing - = false; - } - } - } } else { fts_sync_rollback(sync); } @@ -4656,12 +4646,9 @@ fts_sync( /* Clear fts syncing flags of any indexes incase sync is interrupeted */ for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing == true) { - index_cache->index->index_fts_syncing = false; - } + static_cast( + ib_vector_get(cache->indexes, i)) + ->index->index_fts_syncing = false; } sync->interrupted = false; @@ -4760,9 +4747,17 @@ fts_process_token( t_str.f_str = static_cast( mem_heap_alloc(heap, t_str.f_len)); - newlen = innobase_fts_casedn_str( - doc->charset, (char*) str.f_str, str.f_len, - (char*) t_str.f_str, t_str.f_len); + /* For binary collations, a case sensitive search is + performed. Hence don't convert to lower case. */ + if (my_binary_compare(result_doc->charset)) { + memcpy(t_str.f_str, str.f_str, str.f_len); + t_str.f_str[str.f_len]= 0; + newlen= str.f_len; + } else { + newlen = innobase_fts_casedn_str( + doc->charset, (char*) str.f_str, str.f_len, + (char*) t_str.f_str, t_str.f_len); + } t_str.f_len = newlen; t_str.f_str[newlen] = 0; diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 0b0aecaeaa2cb70d3ade3b21cc77a77e8f08807b..100dbcd70cae01fb13acea4578e70a91ea06c35b 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -3783,10 +3783,19 @@ fts_query_str_preprocess( str_len = query_len * charset->casedn_multiply + 1; str_ptr = static_cast(ut_malloc(str_len)); - *result_len = innobase_fts_casedn_str( - charset, const_cast(reinterpret_cast( - query_str)), query_len, - reinterpret_cast(str_ptr), str_len); + /* For binary collations, a case sensitive search is + performed. Hence don't convert to lower case. */ + if (my_binary_compare(charset)) { + memcpy(str_ptr, query_str, query_len); + str_ptr[query_len]= 0; + *result_len= query_len; + } else { + *result_len = innobase_fts_casedn_str( + charset, const_cast + (reinterpret_cast( query_str)), + query_len, + reinterpret_cast(str_ptr), str_len); + } ut_ad(*result_len < str_len); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 65ac41c26de374c8b239dfec94f67a0d6696a5c3..a7d06617696753d35039293d0960b700da70ad61 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -50,7 +50,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include #endif -#include +#include /** @file ha_innodb.cc */ @@ -367,6 +367,23 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = { }; +/** Possible values for system variable "innodb_default_row_format". */ +static const char* innodb_default_row_format_names[] = { + "redundant", + "compact", + "dynamic", + NullS +}; + +/** Used to define an enumerate type of the system variable +innodb_default_row_format. */ +static TYPELIB innodb_default_row_format_typelib = { + array_elements(innodb_default_row_format_names) - 1, + "innodb_default_row_format_typelib", + innodb_default_row_format_names, + NULL +}; + /* The following counter is used to convey information to InnoDB about server activity: in case of normal DML ops it is not sensible to call srv_active_wake_master_thread after each @@ -387,6 +404,35 @@ static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = { "all" /* IBUF_USE_ALL */ }; + +/** Note we cannot use rec_format_enum because we do not allow +COMPRESSED row format for innodb_default_row_format option. */ +enum default_row_format_enum { + DEFAULT_ROW_FORMAT_REDUNDANT = 0, + DEFAULT_ROW_FORMAT_COMPACT = 1, + DEFAULT_ROW_FORMAT_DYNAMIC = 2 +}; + +/** Convert an InnoDB ROW_FORMAT value. +@param[in] row_format row_format from "innodb_default_row_format" +@return converted ROW_FORMAT */ +static rec_format_t get_row_format(ulong row_format) +{ + switch (row_format) { + case DEFAULT_ROW_FORMAT_REDUNDANT: + return REC_FORMAT_REDUNDANT; + case DEFAULT_ROW_FORMAT_COMPACT: + return REC_FORMAT_COMPACT; + case DEFAULT_ROW_FORMAT_DYNAMIC: + return REC_FORMAT_DYNAMIC; + default: + ut_ad(0); + return REC_FORMAT_COMPACT; + } +} + +static ulong innodb_default_row_format; + /* Call back function array defined by MySQL and used to retrieve FTS results. */ const struct _ft_vft ft_vft_result = {NULL, @@ -1377,19 +1423,12 @@ innobase_close_connection( THD* thd); /*!< in: MySQL thread handle for which to close the connection */ +/** Cancel any pending lock request associated with the current THD. +@sa THD::awake() @sa ha_kill_query() */ +static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels); static void innobase_commit_ordered(handlerton *hton, THD* thd, bool all); static void innobase_checkpoint_request(handlerton *hton, void *cookie); -/*****************************************************************//** -Cancel any pending lock request associated with the current THD. */ -static -void -innobase_kill_connection( -/*======================*/ - handlerton* hton, /*!< in: innobase handlerton */ - THD* thd, /*!< in: handle to the MySQL thread being killed */ - thd_kill_levels); - /*****************************************************************//** Commits a transaction in an InnoDB database or marks an SQL statement ended. @@ -2698,8 +2737,12 @@ innobase_mysql_tmpfile( fd2 = -1; } } +#else +#ifdef F_DUPFD_CLOEXEC + fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); #else fd2 = dup(fd); +#endif #endif if (fd2 < 0) { DBUG_PRINT("error",("Got error %d on dup",fd2)); @@ -3220,8 +3263,7 @@ ha_innobase::ha_innobase( (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) | HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT), start_of_scan(0), - num_write_row(0), - ha_partition_stats(NULL) + num_write_row(0) {} /*********************************************************************//** @@ -3840,7 +3882,7 @@ innobase_init( innobase_hton->release_temporary_latches = innobase_release_temporary_latches; - innobase_hton->kill_query = innobase_kill_connection; + innobase_hton->kill_query = innobase_kill_query; if (srv_file_per_table) innobase_hton->tablefile_extensions = ha_innobase_exts; @@ -4525,6 +4567,14 @@ innobase_init( /* Turn on monitor counters that are default on */ srv_mon_default_on(); +#ifndef UNIV_HOTBACKUP +#ifdef _WIN32 + if (ut_win_init_time()) { + goto mem_free_and_error; + } +#endif /* _WIN32 */ +#endif /* !UNIV_HOTBACKUP */ + DBUG_RETURN(FALSE); error: DBUG_RETURN(TRUE); @@ -5450,23 +5500,13 @@ ha_innobase::get_row_type() const return(ROW_TYPE_NOT_USED); } -/*****************************************************************//** -Cancel any pending lock request associated with the current THD. */ -static -void -innobase_kill_connection( -/*======================*/ - handlerton* hton, /*!< in: innobase handlerton */ - THD* thd, /*!< in: handle to the MySQL thread being killed */ - thd_kill_levels) +/** Cancel any pending lock request associated with the current THD. +@sa THD::awake() @sa ha_kill_query() */ +static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels) { - trx_t* trx; - - DBUG_ENTER("innobase_kill_connection"); - DBUG_ASSERT(hton == innodb_hton_ptr); + DBUG_ENTER("innobase_kill_query"); #ifdef WITH_WSREP - wsrep_thd_LOCK(thd); if (wsrep_thd_get_conflict_state(thd) != NO_CONFLICT) { /* if victim has been signaled by BF thread and/or aborting is already progressing, following query aborting is not necessary @@ -5474,55 +5514,40 @@ innobase_kill_connection( Also, BF thread should own trx mutex for the victim, which would conflict with trx_mutex_enter() below */ - wsrep_thd_UNLOCK(thd); DBUG_VOID_RETURN; } - wsrep_thd_UNLOCK(thd); #endif /* WITH_WSREP */ - trx = thd_to_trx(thd); + if (trx_t* trx = thd_to_trx(thd)) { + ut_ad(trx->mysql_thd == thd); - if (trx && trx->lock.wait_lock) { - /* In wsrep BF we have already took lock_sys and trx - mutex either on wsrep_abort_transaction() or - before wsrep_kill_victim(). In replication we - could own lock_sys mutex taken in - lock_deadlock_check_and_resolve().*/ - - WSREP_DEBUG("Killing victim trx %p BF %d trx BF %d trx_id " TRX_ID_FMT " ABORT %d thd %p" - " current_thd %p BF %d wait_lock_modes: %s\n", - trx, wsrep_thd_is_BF(trx->mysql_thd, FALSE), - wsrep_thd_is_BF(thd, FALSE), - trx->id, trx->abort_type, - trx->mysql_thd, - current_thd, - wsrep_thd_is_BF(current_thd, FALSE), - lock_get_info(trx->lock.wait_lock).c_str()); - - if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE) - && trx->abort_type == TRX_SERVER_ABORT) { - ut_ad(!lock_mutex_own()); - lock_mutex_enter(); - } - - if (trx->abort_type != TRX_WSREP_ABORT) { + switch (trx->abort_type) { +#ifdef WITH_WSREP + case TRX_WSREP_ABORT: + break; +#endif + case TRX_SERVER_ABORT: + if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + lock_mutex_enter(); + } + /* fall through */ + case TRX_REPLICATION_ABORT: trx_mutex_enter(trx); } - - ut_ad(lock_mutex_own()); - ut_ad(trx_mutex_own(trx)); - - if (trx->lock.wait_lock) { - lock_cancel_waiting_and_release(trx->lock.wait_lock); - } - - if (trx->abort_type != TRX_WSREP_ABORT) { + /* Cancel a pending lock request if there are any */ + lock_trx_handle_wait(trx); + switch (trx->abort_type) { +#ifdef WITH_WSREP + case TRX_WSREP_ABORT: + break; +#endif + case TRX_SERVER_ABORT: + if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + lock_mutex_exit(); + } + /* fall through */ + case TRX_REPLICATION_ABORT: trx_mutex_exit(trx); } - - if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - trx->abort_type == TRX_SERVER_ABORT) { - lock_mutex_exit(); - } } DBUG_VOID_RETURN; @@ -9000,14 +9025,12 @@ ha_innobase::write_row( user_thd); #ifdef WITH_WSREP - if (!error_result && - wsrep_thd_exec_mode(user_thd) == LOCAL_STATE && - wsrep_on(user_thd) && - !wsrep_consistency_check(user_thd) && - !wsrep_thd_ignore_table(user_thd)) - { - if (wsrep_append_keys(user_thd, false, record, NULL)) - { + if (!error_result + && wsrep_on(user_thd) + && wsrep_thd_exec_mode(user_thd) == LOCAL_STATE + && !wsrep_consistency_check(user_thd) + && !wsrep_thd_ignore_table(user_thd)) { + if (wsrep_append_keys(user_thd, false, record, NULL)) { DBUG_PRINT("wsrep", ("row key failed")); error_result = HA_ERR_INTERNAL_ERROR; goto wsrep_error; @@ -9626,7 +9649,7 @@ ha_innobase::unlock_row(void) But there are some calls to this function from the SQL layer when the transaction is in state TRX_STATE_NOT_STARTED. The check on prebuilt->select_lock_type above gets around this issue. */ - ut_ad(trx_state_eq(prebuilt->trx, TRX_STATE_ACTIVE)); + ut_ad(trx_state_eq(prebuilt->trx, TRX_STATE_ACTIVE, true)); switch (prebuilt->row_read_type) { case ROW_READ_WITH_LOCKS: @@ -11896,8 +11919,6 @@ create_options_are_invalid( CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; break; case ROW_TYPE_DYNAMIC: - CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace); - CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE; /* ROW_FORMAT=DYNAMIC also shuns KEY_BLOCK_SIZE */ /* fall through */ case ROW_TYPE_COMPACT: @@ -12132,7 +12153,8 @@ innobase_table_flags( bool zip_allowed = true; ulint zip_ssize = 0; enum row_type row_format; - rec_format_t innodb_row_format = REC_FORMAT_COMPACT; + rec_format_t innodb_row_format = + get_row_format(innodb_default_row_format); bool use_data_dir; ha_table_option_struct *options= form->s->option_struct; @@ -12274,38 +12296,29 @@ innobase_table_flags( /* Validate the row format. Correct it if necessary */ switch (row_format) { + case ROW_TYPE_DEFAULT: + break; case ROW_TYPE_REDUNDANT: innodb_row_format = REC_FORMAT_REDUNDANT; break; - - case ROW_TYPE_COMPRESSED: case ROW_TYPE_DYNAMIC: + innodb_row_format = REC_FORMAT_DYNAMIC; + break; + case ROW_TYPE_COMPRESSED: if (!use_tablespace) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_per_table."); } else if (file_format_allowed == UNIV_FORMAT_A) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); + "InnoDB: ROW_FORMAT=COMPRESSED requires" + " innodb_file_format > Antelope."); } else { - switch(row_format) { - case ROW_TYPE_COMPRESSED: - innodb_row_format = REC_FORMAT_COMPRESSED; - break; - case ROW_TYPE_DYNAMIC: - innodb_row_format = REC_FORMAT_DYNAMIC; - break; - default: - /* Not possible, avoid compiler warning */ - break; - } + innodb_row_format = REC_FORMAT_COMPRESSED; break; /* Correct row_format */ } zip_allowed = FALSE; @@ -12320,11 +12333,8 @@ innobase_table_flags( ER_ILLEGAL_HA_CREATE_OPTION, "InnoDB: assuming ROW_FORMAT=COMPACT."); /* fall through */ - case ROW_TYPE_DEFAULT: - /* If we fell through, set row format to Compact. */ - row_format = ROW_TYPE_COMPACT; - /* fall through */ case ROW_TYPE_COMPACT: + innodb_row_format = REC_FORMAT_COMPACT; break; } @@ -14514,6 +14524,7 @@ ha_innobase::optimize( This works OK otherwise, but MySQL locks the entire table during calls to OPTIMIZE, which is undesirable. */ + bool try_alter = true; if (srv_defragment) { int err; @@ -14521,7 +14532,7 @@ ha_innobase::optimize( err = defragment_table(prebuilt->table->name, NULL, false); if (err == 0) { - return (HA_ADMIN_OK); + try_alter = false; } else { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, err, @@ -14529,9 +14540,7 @@ ha_innobase::optimize( prebuilt->table->name, err); if(err == ER_SP_ALREADY_EXISTS) { - return (HA_ADMIN_OK); - } else { - return (HA_ADMIN_TRY_ALTER); + try_alter = false; } } } @@ -14542,11 +14551,10 @@ ha_innobase::optimize( fts_sync_table(prebuilt->table, false, true, false); fts_optimize_table(prebuilt->table); } - return(HA_ADMIN_OK); - } else { - - return(HA_ADMIN_TRY_ALTER); + try_alter = false; } + + return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK; } /*******************************************************************//** @@ -17518,13 +17526,6 @@ innodb_max_dirty_pages_pct_lwm_update( srv_max_dirty_pages_pct_lwm = in_val; } -UNIV_INTERN -void -ha_innobase::set_partition_owner_stats(ha_statistics *stats) -{ - ha_partition_stats= stats; -} - /************************************************************//** Validate the file format name and return its corresponding id. @return valid file format id */ @@ -19769,7 +19770,7 @@ wsrep_innobase_kill_one_trx( thd_get_thread_id(thd))); WSREP_DEBUG("kill query for: %ld", thd_get_thread_id(thd)); - /* Note that innobase_kill_connection will take lock_mutex + /* Note that innobase_kill_query will take lock_mutex and trx_mutex */ wsrep_thd_UNLOCK(thd); wsrep_thd_awake(thd, signal); @@ -21115,6 +21116,14 @@ static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled, "may have negative impact on performance (off by default)", NULL, innodb_cmp_per_index_update, FALSE); +static MYSQL_SYSVAR_ENUM(default_row_format, innodb_default_row_format, + PLUGIN_VAR_RQCMDARG, + "The default ROW FORMAT for all innodb tables created without explicit" + " ROW_FORMAT. Possible values are REDUNDANT, COMPACT, and DYNAMIC." + " The ROW_FORMAT value COMPRESSED is not allowed", + NULL, NULL, DEFAULT_ROW_FORMAT_COMPACT, + &innodb_default_row_format_typelib); + #ifdef UNIV_DEBUG static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT, @@ -21558,6 +21567,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(sync_array_size), MYSQL_SYSVAR(compression_failure_threshold_pct), MYSQL_SYSVAR(compression_pad_pct_max), + MYSQL_SYSVAR(default_row_format), #ifdef UNIV_DEBUG MYSQL_SYSVAR(trx_rseg_n_slots_debug), MYSQL_SYSVAR(limit_optimistic_insert_debug), diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index c5b0e72370268b653f837c9db060d82661aad6af..3dbbc53a0e33bc09085aa411165ba45503fa6e04 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -100,8 +100,6 @@ class ha_innobase: public handler or undefined */ uint num_write_row; /*!< number of write_row() calls */ - ha_statistics* ha_partition_stats; /*!< stats of the partition owner - handler (if there is one) */ uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, const uchar* record); inline void update_thd(THD* thd); @@ -318,7 +316,6 @@ class ha_innobase: public handler Alter_inplace_info* ha_alter_info, bool commit); /** @} */ - void set_partition_owner_stats(ha_statistics *stats); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 2a2c466fd4f627361ae751d8aebf8c4005ab58a3..131939bcdb2f92203504dbb968764b3e445fa1cf 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -1622,6 +1622,7 @@ innobase_create_index_def( if (key_clustered) { DBUG_ASSERT(!(key->flags & HA_FULLTEXT)); + DBUG_ASSERT(key->flags & HA_NOSAME); index->ind_type |= DICT_CLUSTERED; } else if (key->flags & HA_FULLTEXT) { DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK @@ -1937,14 +1938,9 @@ innobase_create_key_defs( ulint primary_key_number; if (new_primary) { - if (n_add == 0) { - DBUG_ASSERT(got_default_clust); - DBUG_ASSERT(altered_table->s->primary_key - == 0); - primary_key_number = 0; - } else { - primary_key_number = *add; - } + DBUG_ASSERT(n_add || got_default_clust); + DBUG_ASSERT(n_add || !altered_table->s->primary_key); + primary_key_number = altered_table->s->primary_key; } else if (got_default_clust) { /* Create the GEN_CLUST_INDEX */ index_def_t* index = indexdef++; @@ -4433,12 +4429,16 @@ rollback_inplace_alter_table( row_mysql_lock_data_dictionary(ctx->trx); if (ctx->need_rebuild()) { - dberr_t err; - ulint flags = ctx->new_table->flags; - /* DML threads can access ctx->new_table via the online rebuild log. Free it first. */ innobase_online_rebuild_log_free(prebuilt->table); + } + + if (!ctx->new_table) { + ut_ad(ctx->need_rebuild()); + } else if (ctx->need_rebuild()) { + dberr_t err; + ulint flags = ctx->new_table->flags; /* Since the FTS index specific auxiliary tables has not yet registered with "table->fts" by fts_add_index(), @@ -5800,21 +5800,6 @@ ha_innobase::commit_inplace_alter_table( ut_ad(prebuilt->table == ctx0->old_table); ha_alter_info->group_commit_ctx = NULL; - /* Free the ctx->trx of other partitions, if any. We will only - use the ctx0->trx here. Others may have been allocated in - the prepare stage. */ - - for (inplace_alter_handler_ctx** pctx = &ctx_array[1]; *pctx; - pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); - - if (ctx->trx) { - trx_free_for_mysql(ctx->trx); - ctx->trx = NULL; - } - } - trx_start_if_not_started_xa(prebuilt->trx); for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { @@ -6193,10 +6178,6 @@ ha_innobase::commit_inplace_alter_table( covering all partitions. */ share->idx_trans_tbl.index_count = 0; - if (trx == ctx0->trx) { - ctx0->trx = NULL; - } - /* Tell the InnoDB server that there might be work for utility threads: */ @@ -6219,10 +6200,31 @@ ha_innobase::commit_inplace_alter_table( } row_mysql_unlock_data_dictionary(trx); - trx_free_for_mysql(trx); + if (trx != ctx0->trx) { + trx_free_for_mysql(trx); + } DBUG_RETURN(true); } + if (trx == ctx0->trx) { + ctx0->trx = NULL; + } + + /* Free the ctx->trx of other partitions, if any. We will only + use the ctx0->trx here. Others may have been allocated in + the prepare stage. */ + + for (inplace_alter_handler_ctx** pctx = &ctx_array[1]; *pctx; + pctx++) { + ha_innobase_inplace_ctx* ctx + = static_cast(*pctx); + + if (ctx->trx) { + trx_free_for_mysql(ctx->trx); + ctx->trx = NULL; + } + } + /* Release the table locks. */ trx_commit_for_mysql(prebuilt->trx); diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index 94cd6f29558b90c161997ee319405705cad6d93f..dc4fa99fc560f8c5e5c073bfdd16e11fc8d45432 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -4922,9 +4922,11 @@ i_s_innodb_buffer_page_fill( mutex_enter(&dict_sys->mutex); - if (const dict_index_t* index = - dict_index_get_if_in_cache_low( - page_info->index_id)) { + const dict_index_t* index = + dict_index_get_if_in_cache_low( + page_info->index_id); + + if (index) { table_name_end = innobase_convert_name( table_name, sizeof(table_name), index->table_name, @@ -4947,7 +4949,10 @@ i_s_innodb_buffer_page_fill( OK(ret); - fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull(); + if (index) { + fields[IDX_BUFFER_PAGE_TABLE_NAME] + ->set_notnull(); + } } OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store( @@ -5621,9 +5626,11 @@ i_s_innodb_buf_page_lru_fill( mutex_enter(&dict_sys->mutex); - if (const dict_index_t* index = - dict_index_get_if_in_cache_low( - page_info->index_id)) { + const dict_index_t* index = + dict_index_get_if_in_cache_low( + page_info->index_id); + + if (index) { table_name_end = innobase_convert_name( table_name, sizeof(table_name), index->table_name, @@ -5646,7 +5653,10 @@ i_s_innodb_buf_page_lru_fill( OK(ret); - fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull(); + if (index) { + fields[IDX_BUF_LRU_PAGE_TABLE_NAME] + ->set_notnull(); + } } OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store( diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc index b169916c34eb5f9c480b88d1360303f7799095f8..96a86eea4c19d5eb5512028a12bb92a031241151 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.cc +++ b/storage/xtradb/ibuf/ibuf0ibuf.cc @@ -5218,6 +5218,10 @@ ibuf_check_bitmap_on_import( bitmap_page = ibuf_bitmap_get_map_page( space_id, page_no, zip_size, &mtr); + if (!bitmap_page) { + mutex_exit(&ibuf_mutex); + return DB_CORRUPTION; + } for (i = FSP_IBUF_BITMAP_OFFSET + 1; i < page_size; i++) { const ulint offset = page_no + i; diff --git a/storage/xtradb/include/btr0sea.h b/storage/xtradb/include/btr0sea.h index bfe2c43defbbb3d897750d534318a6e81378fcf0..55366d3c0d3f22cbec6a5993b1b7e22b4592cd50 100644 --- a/storage/xtradb/include/btr0sea.h +++ b/storage/xtradb/include/btr0sea.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, 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 @@ -142,17 +143,11 @@ btr_search_drop_page_hash_index( s- or x-latched, or an index page for which we know that block->buf_fix_count == 0 */ -/********************************************************************//** -Drops a possible page hash index when a page is evicted from the buffer pool -or freed in a file segment. */ +/** Drop possible adaptive hash index entries when a page is evicted +from the buffer pool or freed in a file, or the index is being dropped. */ UNIV_INTERN void -btr_search_drop_page_hash_when_freed( -/*=================================*/ - ulint space, /*!< in: space id */ - ulint zip_size, /*!< in: compressed page size in bytes - or 0 for uncompressed pages */ - ulint page_no); /*!< in: page number */ +btr_search_drop_page_hash_when_freed(ulint space, ulint page_no); /********************************************************************//** Updates the page hash index when a single record is inserted on a page. */ UNIV_INTERN diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index 7661ba1785d5c166aeba7b22caa5f10ba67a630a..0944b5d4067056f8b804585d2b216ad2fde89f18 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, 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 @@ -38,6 +38,7 @@ Created 11/5/1995 Heikki Tuuri #include "ut0rbt.h" #include "os0proc.h" #include "log0log.h" +#include "my_atomic.h" /** @name Modes for buf_page_get_gen */ /* @{ */ @@ -1528,45 +1529,16 @@ buf_page_encrypt_before_write( buf_page_t* bpage, byte* src_frame); -/********************************************************************** -The hook that is called after page is written to disk. -The function releases any resources needed for encryption that was allocated -in buf_page_encrypt_before_write */ -UNIV_INTERN -ibool -buf_page_encrypt_after_write( -/*=========================*/ - buf_page_t* page); /*!< in/out: buffer page that was flushed */ - -/********************************************************************//** -The hook that is called just before a page is read from disk. -The function allocates memory that is used to temporarily store disk content -before getting decrypted */ -UNIV_INTERN -byte* -buf_page_decrypt_before_read( -/*=========================*/ - buf_page_t* page, /*!< in/out: buffer page read from disk */ - ulint zip_size); /*!< in: compressed page size, or 0 */ - -/********************************************************************//** -The hook that is called just after a page is read from disk. -The function decrypt disk content into buf_page_t and releases the -temporary buffer that was allocated in buf_page_decrypt_before_read */ -UNIV_INTERN -bool -buf_page_decrypt_after_read( -/*========================*/ - buf_page_t* page); /*!< in/out: buffer page read from disk */ - /** @brief The temporary memory structure. NOTE! The definition appears here only for other modules of this directory (buf) to see it. Do not use from outside! */ typedef struct { - bool reserved; /*!< true if this slot is reserved +private: + int32 reserved; /*!< true if this slot is reserved */ +public: byte* crypt_buf; /*!< for encryption the data needs to be copied to a separate buffer before it's encrypted&written. this as a page can be @@ -1577,6 +1549,21 @@ typedef struct { byte* out_buf; /*!< resulting buffer after encryption/compression. This is a pointer and not allocated. */ + + /** Release the slot */ + void release() + { + my_atomic_store32_explicit(&reserved, false, + MY_MEMORY_ORDER_RELAXED); + } + + /** Acquire the slot + @return whether the slot was acquired */ + bool acquire() + { + return !my_atomic_fas32_explicit(&reserved, true, + MY_MEMORY_ORDER_RELAXED); + } } buf_tmp_buffer_t; /** The common buffer control block structure diff --git a/storage/xtradb/include/buf0lru.h b/storage/xtradb/include/buf0lru.h index 1bc11937fa1cad50964c470798e03c1d2d21a815..f0ba1bb227d6ecc4091c804ec43700887b89c83e 100644 --- a/storage/xtradb/include/buf0lru.h +++ b/storage/xtradb/include/buf0lru.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -36,6 +36,7 @@ Created 11/5/1995 Heikki Tuuri // Forward declaration struct trx_t; +struct dict_table_t; /******************************************************************//** Returns TRUE if less than 25 % of the buffer pool is available. This can be @@ -54,14 +55,15 @@ These are low-level functions /** Minimum LRU list length for which the LRU_old pointer is defined */ #define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */ +/** Drop the adaptive hash index for a tablespace. +@param[in,out] table table */ +UNIV_INTERN void buf_LRU_drop_page_hash_for_tablespace(dict_table_t* table); + /** Empty the flush list for all pages belonging to a tablespace. @param[in] id tablespace identifier @param[in] trx transaction, for checking for user interrupt; - or NULL if nothing is to be written -@param[in] drop_ahi whether to drop the adaptive hash index */ -UNIV_INTERN -void -buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx, bool drop_ahi=false); + or NULL if nothing is to be written */ +UNIV_INTERN void buf_LRU_flush_or_remove_pages(ulint id, const trx_t* trx); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** diff --git a/storage/xtradb/include/data0type.ic b/storage/xtradb/include/data0type.ic index 96b001e197eab156978a0bc160945463a8e32e69..a7e2eb0682c04b4ab6bed2454153075cf9a9da1a 100644 --- a/storage/xtradb/include/data0type.ic +++ b/storage/xtradb/include/data0type.ic @@ -525,6 +525,7 @@ dtype_get_fixed_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: @@ -602,6 +603,7 @@ dtype_get_min_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 8c3bf7d2b062bf7b9eac27d6b70f8a39f6ff281c..7b8339fec7d74529b403a6fb19b4e4798033d817 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -170,8 +170,7 @@ extern fil_addr_t fil_addr_null; #define FIL_PAGE_TYPE_BLOB 10 /*!< Uncompressed BLOB page */ #define FIL_PAGE_TYPE_ZBLOB 11 /*!< First compressed BLOB page */ #define FIL_PAGE_TYPE_ZBLOB2 12 /*!< Subsequent compressed BLOB page */ -#define FIL_PAGE_TYPE_COMPRESSED 13 /*!< Compressed page */ -#define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_COMPRESSED +#define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_ZBLOB2 /*!< Last page type */ /* @} */ @@ -275,10 +274,6 @@ struct fil_space_t { an insert buffer merge request for a page because it actually was for the previous incarnation of the space */ - ibool stop_ios;/*!< TRUE if we want to rename the - .ibd file of tablespace and want to - stop temporarily posting of new i/o - requests on the file */ bool stop_new_ops; /*!< we set this true when we start deleting a single-table tablespace. @@ -345,9 +340,6 @@ struct fil_space_t { corrupted page. */ bool is_corrupt; /*!< true if tablespace corrupted */ - bool printed_compression_failure; - /*!< true if we have already printed - compression failure */ fil_space_crypt_t* crypt_data; /*!< tablespace crypt data or NULL */ ulint file_block_size; @@ -1309,107 +1301,6 @@ fil_delete_file( /*============*/ const char* path); /*!< in: filepath of the ibd tablespace */ -/** Callback functor. */ -struct PageCallback { - - /** - Default constructor */ - PageCallback() - : - m_zip_size(), - m_page_size(), - m_filepath() UNIV_NOTHROW {} - - virtual ~PageCallback() UNIV_NOTHROW {} - - /** - Called for page 0 in the tablespace file at the start. - @param file_size - size of the file in bytes - @param block - contents of the first page in the tablespace file - @retval DB_SUCCESS or error code.*/ - virtual dberr_t init( - os_offset_t file_size, - const buf_block_t* block) UNIV_NOTHROW = 0; - - /** - Called for every page in the tablespace. If the page was not - updated then its state must be set to BUF_PAGE_NOT_USED. For - compressed tables the page descriptor memory will be at offset: - block->frame + UNIV_PAGE_SIZE; - @param offset - physical offset within the file - @param block - block read from file, note it is not from the buffer pool - @retval DB_SUCCESS or error code. */ - virtual dberr_t operator()( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW = 0; - - /** - Set the name of the physical file and the file handle that is used - to open it for the file that is being iterated over. - @param filename - then physical name of the tablespace file. - @param file - OS file handle */ - void set_file(const char* filename, pfs_os_file_t file) UNIV_NOTHROW - { - m_file = file; - m_filepath = filename; - } - - /** - @return the space id of the tablespace */ - virtual ulint get_space_id() const UNIV_NOTHROW = 0; - - /** The compressed page size - @return the compressed page size */ - ulint get_zip_size() const - { - return(m_zip_size); - } - - /** - Set the tablespace compressed table size. - @return DB_SUCCESS if it is valie or DB_CORRUPTION if not */ - dberr_t set_zip_size(const buf_frame_t* page) UNIV_NOTHROW; - - /** The compressed page size - @return the compressed page size */ - ulint get_page_size() const - { - return(m_page_size); - } - - /** Compressed table page size */ - ulint m_zip_size; - - /** The tablespace page size. */ - ulint m_page_size; - - /** File handle to the tablespace */ - pfs_os_file_t m_file; - - /** Physical file path. */ - const char* m_filepath; - -protected: - // Disable copying - PageCallback(const PageCallback&); - PageCallback& operator=(const PageCallback&); -}; - -/********************************************************************//** -Iterate over all the pages in the tablespace. -@param table - the table definiton in the server -@param n_io_buffers - number of blocks to read and write together -@param callback - functor that will do the page updates -@return DB_SUCCESS or error code */ -UNIV_INTERN -dberr_t -fil_tablespace_iterate( -/*===================*/ - dict_table_t* table, - ulint n_io_buffers, - PageCallback& callback) - MY_ATTRIBUTE((nonnull, warn_unused_result)); - /*******************************************************************//** Checks if a single-table tablespace for a given table name exists in the tablespace memory cache. diff --git a/storage/xtradb/include/fil0fil.ic b/storage/xtradb/include/fil0fil.ic index 6c2504c9f8c0423c4c8154f90c81211cd4eb81e7..3f21c5293081e17e044f2a0be11676a3c286c306 100644 --- a/storage/xtradb/include/fil0fil.ic +++ b/storage/xtradb/include/fil0fil.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, 2017, MariaDB Corporation. +Copyright (c) 2015, 2018, 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 @@ -65,12 +65,9 @@ fil_get_page_type_name( return "ZBLOB"; case FIL_PAGE_TYPE_ZBLOB2: return "ZBLOB2"; - case FIL_PAGE_TYPE_COMPRESSED: - return "ORACLE PAGE COMPRESSED"; } return "PAGE TYPE CORRUPTED"; - } /****************************************************************//** @@ -112,8 +109,7 @@ fil_page_type_validate( page_type == FIL_PAGE_TYPE_XDES || page_type == FIL_PAGE_TYPE_BLOB || page_type == FIL_PAGE_TYPE_ZBLOB || - page_type == FIL_PAGE_TYPE_ZBLOB2 || - page_type == FIL_PAGE_TYPE_COMPRESSED))) { + page_type == FIL_PAGE_TYPE_ZBLOB2))) { ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED); diff --git a/storage/xtradb/include/fil0pagecompress.h b/storage/xtradb/include/fil0pagecompress.h index 03e16699ce383e3f21c02ef716e4a6462aaea4ab..934372c55b2a45169f07b4e0d11d21ab37aac309 100644 --- a/storage/xtradb/include/fil0pagecompress.h +++ b/storage/xtradb/include/fil0pagecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (C) 2013, 2017 MariaDB Corporation. All Rights Reserved. +Copyright (C) 2013, 2018 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 @@ -30,70 +30,26 @@ atomic writes information to table space. Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com ***********************************************************************/ -/*******************************************************************//** -Find out wheather the page is index page or not -@return true if page type index page, false if not */ -UNIV_INLINE -ibool -fil_page_is_index_page( -/*===================*/ - byte *buf); /*!< in: page */ - -/****************************************************************//** -Get the name of the compression algorithm used for page -compression. -@return compression algorithm name or "UNKNOWN" if not known*/ -UNIV_INLINE -const char* -fil_get_compression_alg_name( -/*=========================*/ - ulint comp_alg); /*!mutex and sometimes by trx->mutex. */ -typedef enum { +enum trx_abort_t { TRX_SERVER_ABORT = 0, - TRX_WSREP_ABORT = 1, - TRX_REPLICATION_ABORT = 2 -} trx_abort_t; +#ifdef WITH_WSREP + TRX_WSREP_ABORT, +#endif + TRX_REPLICATION_ABORT +}; struct trx_t{ ulint magic_n; diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 93ab71bf46c856810723ad927aa63cd9d9c50c27..7e1a6b0eeacd1877e91ebb855977158c05e66052 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 36 +#define INNODB_VERSION_BUGFIX 39 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 83.0 +#define PERCONA_INNODB_VERSION 83.1 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ @@ -73,6 +73,10 @@ component, i.e. we show M.N.P as M.N */ IB_TO_STR(INNODB_VERSION_MAJOR) "." \ IB_TO_STR(INNODB_VERSION_MINOR) "/en/" +/** How far ahead should we tell the service manager the timeout +(time in seconds) */ +#define INNODB_EXTEND_TIMEOUT_INTERVAL 30 + #ifdef MYSQL_DYNAMIC_PLUGIN /* In the dynamic plugin, redefine some externally visible symbols in order not to conflict with the symbols of a builtin InnoDB. */ diff --git a/storage/xtradb/include/ut0timer.h b/storage/xtradb/include/ut0timer.h index f361ae79bf525f6784ddffff7c4ee3523fdc25fc..3015771b434d7268f7258155fbb7ef4e18041383 100644 --- a/storage/xtradb/include/ut0timer.h +++ b/storage/xtradb/include/ut0timer.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. -Copyright (c) 2014, SkySQL Ab. All Rights Reserved. +Copyright (c) 2014, 2018, 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 @@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc., /********************************************************************//** @file include/ut0timer.h -Timer rountines +Timer routines Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 @@ -28,8 +28,6 @@ modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11 #define ut0timer_h #include "univ.i" -#include "data0type.h" -#include /* Current timer stats */ extern struct my_timer_unit_info ut_timer; @@ -47,39 +45,6 @@ Initializes my_timer struct to contain the info for selected timer.*/ UNIV_INTERN void ut_init_timer(void); -/**************************************************************//** -Return time passed since time then, automatically adjusted -for the estimated timer overhead. -@return time passed since "then" */ -UNIV_INLINE -ulonglong -ut_timer_since( -/*===========*/ - ulonglong then); /*!< in: time where to calculate */ -/**************************************************************//** -Get time passed since "then", and update then to now -@return time passed sinche "then" */ -UNIV_INLINE -ulonglong -ut_timer_since_and_update( -/*======================*/ - ulonglong *then); /*!< in: time where to calculate */ -/**************************************************************//** -Convert native timer units in a ulonglong into seconds in a double -@return time in a seconds */ -UNIV_INLINE -double -ut_timer_to_seconds( -/*=================*/ - ulonglong when); /*!< in: time where to calculate */ -/**************************************************************//** -Convert native timer units in a ulonglong into milliseconds in a double -@return time in milliseconds */ -UNIV_INLINE -double -ut_timer_to_milliseconds( -/*=====================*/ - ulonglong when); /*!< in: time where to calculate */ /**************************************************************//** Convert native timer units in a ulonglong into microseconds in a double @return time in microseconds */ diff --git a/storage/xtradb/include/ut0timer.ic b/storage/xtradb/include/ut0timer.ic index 815726e9d0a1c359c3d3cd4590cc0a342fd5a7fb..02af23cdc6df7db37cd77b474d02d101353b6ea4 100644 --- a/storage/xtradb/include/ut0timer.ic +++ b/storage/xtradb/include/ut0timer.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. -Copyright (c) 2014, SkySQL Ab. All Rights Reserved. +Copyright (c) 2014, 2018, 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 @@ -19,69 +19,12 @@ this program; if not, write to the Free Software Foundation, Inc., /********************************************************************//** @file include/ut0timer.ic -Timer rountines +Timer routines Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 *************************************************************************/ -/**************************************************************//** -Return time passed since time then, automatically adjusted -for the estimated timer overhead. -@return time passed since "then" */ -UNIV_INLINE -ulonglong -ut_timer_since( -/*===========*/ - ulonglong then) /*!< in: time where to calculate */ -{ - return (ut_timer_now() - then) - ut_timer.overhead; -} - -/**************************************************************//** -Get time passed since "then", and update then to now -@return time passed sinche "then" */ -UNIV_INLINE -ulonglong -ut_timer_since_and_update( -/*======================*/ - ulonglong *then) /*!< in: time where to calculate */ -{ - ulonglong now = ut_timer_now(); - ulonglong ret = (now - (*then)) - ut_timer.overhead; - *then = now; - return ret; -} - -/**************************************************************//** -Convert native timer units in a ulonglong into seconds in a double -@return time in a seconds */ -UNIV_INLINE -double -ut_timer_to_seconds( -/*=================*/ - ulonglong when) /*!< in: time where to calculate */ -{ - double ret = (double)(when); - ret /= (double)(ut_timer.frequency); - return ret; -} - -/**************************************************************//** -Convert native timer units in a ulonglong into milliseconds in a double -@return time in milliseconds */ -UNIV_INLINE -double -ut_timer_to_milliseconds( -/*=====================*/ - ulonglong when) /*!< in: time where to calculate */ -{ - double ret = (double)(when); - ret *= 1000.0; - ret /= (double)(ut_timer.frequency); - return ret; -} - /**************************************************************//** Convert native timer units in a ulonglong into microseconds in a double @return time in microseconds */ diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 5fba1c7f547bf5866d3943b29f4823a04473daee..726c01a2e0fda41fa0226513e9353d6153e24910 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -283,6 +283,15 @@ UNIV_INTERN ulint ut_time_ms(void); /*============*/ +#ifdef _WIN32 +/**********************************************************//** +Initialise highest available time resolution API on Windows +@return 0 if all OK else -1 */ +int +ut_win_init_time(); + +#endif /* _WIN32 */ + #endif /* !UNIV_HOTBACKUP */ /**********************************************************//** diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index a9077cb19a37c401abfcc41992b5bc5389aeeaf2..549cc411f69754b9675027e2190c51c4e519efac 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -910,7 +910,7 @@ UNIV_INLINE void lock_reset_lock_and_trx_wait( /*=========================*/ - lock_t* lock) /*!< in/out: record lock */ + lock_t* lock) /*!< in/out: record lock */ { ut_ad(lock_get_wait(lock)); ut_ad(lock_mutex_own()); @@ -2358,13 +2358,6 @@ lock_rec_create( trx_mutex_enter(trx); } - /* trx might not wait for c_lock, but some other lock - does not matter if wait_lock was released above - */ - if (c_lock->trx->lock.wait_lock == c_lock) { - lock_reset_lock_and_trx_wait(lock); - } - trx_mutex_exit(c_lock->trx); if (wsrep_debug) { @@ -5010,19 +5003,18 @@ lock_table_create( UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); #ifdef WITH_WSREP - if (wsrep_thd_is_wsrep(trx->mysql_thd)) { - if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + if (c_lock) { + if (wsrep_thd_is_wsrep(trx->mysql_thd) + && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { UT_LIST_INSERT_AFTER( un_member.tab_lock.locks, table->locks, c_lock, lock); } else { UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); } - if (c_lock) { - trx_mutex_enter(c_lock->trx); - } + trx_mutex_enter(c_lock->trx); - if (c_lock && c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { + if (c_lock->trx->lock.que_state == TRX_QUE_LOCK_WAIT) { c_lock->trx->lock.was_chosen_as_deadlock_victim = TRUE; @@ -5031,36 +5023,21 @@ lock_table_create( wsrep_print_wait_locks(c_lock->trx->lock.wait_lock); } - /* have to release trx mutex for the duration of - victim lock release. This will eventually call - lock_grant, which wants to grant trx mutex again - */ - /* caller has trx_mutex, have to release for lock cancel */ + /* The lock release will call lock_grant(), + which would acquire trx->mutex again. */ trx_mutex_exit(trx); lock_cancel_waiting_and_release(c_lock->trx->lock.wait_lock); trx_mutex_enter(trx); - /* trx might not wait for c_lock, but some other lock - does not matter if wait_lock was released above - */ - if (c_lock->trx->lock.wait_lock == c_lock) { - lock_reset_lock_and_trx_wait(lock); - } - if (wsrep_debug) { fprintf(stderr, "WSREP: c_lock canceled " TRX_ID_FMT "\n", c_lock->trx->id); } } - if (c_lock) { - trx_mutex_exit(c_lock->trx); - } - } else { + trx_mutex_exit(c_lock->trx); + } else #endif /* WITH_WSREP */ UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); -#ifdef WITH_WSREP - } -#endif /* WITH_WSREP */ if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) { @@ -6978,10 +6955,10 @@ lock_rec_block_validate( page_no, RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr); - - buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); - - ut_ad(lock_rec_validate_page(block)); + if (block) { + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + ut_ad(lock_rec_validate_page(block)); + } mtr_commit(&mtr); fil_space_release(space); @@ -8042,7 +8019,10 @@ lock_trx_release_locks( } mutex_exit(&trx_sys->mutex); } else { - ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); + ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) + || (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) + && trx->is_recovered + && !UT_LIST_GET_LEN(trx->lock.trx_locks))); } /* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY @@ -8107,26 +8087,19 @@ lock_trx_handle_wait( /*=================*/ trx_t* trx) /*!< in/out: trx lock state */ { - dberr_t err; - - lock_mutex_enter(); - - trx_mutex_enter(trx); + ut_ad(lock_mutex_own()); + ut_ad(trx_mutex_own(trx)); if (trx->lock.was_chosen_as_deadlock_victim) { - err = DB_DEADLOCK; - } else if (trx->lock.wait_lock != NULL) { - lock_cancel_waiting_and_release(trx->lock.wait_lock); - err = DB_LOCK_WAIT; - } else { + return DB_DEADLOCK; + } + if (!trx->lock.wait_lock) { /* The lock was probably granted before we got here. */ - err = DB_SUCCESS; + return DB_SUCCESS; } - lock_mutex_exit(); - trx_mutex_exit(trx); - - return(err); + lock_cancel_waiting_and_release(trx->lock.wait_lock); + return DB_LOCK_WAIT; } /*********************************************************************//** diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc index 8f8984f8880fd720dd3af4cdeb6bc2cd56c64709..1420f5a3a12bd52cb1265a6bab1fd9ff5238b42c 100644 --- a/storage/xtradb/log/log0log.cc +++ b/storage/xtradb/log/log0log.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -49,7 +49,7 @@ Created 12/9/1995 Heikki Tuuri #ifndef UNIV_HOTBACKUP #if MYSQL_VERSION_ID < 100200 -# include /* sd_notifyf() */ +# include #endif #include "mem0mem.h" @@ -1561,6 +1561,12 @@ log_write_up_to( return; } + if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "log write up to: " LSN_PF, + lsn); + } + loop: ut_ad(++loop_count < 100); @@ -2602,8 +2608,9 @@ log_group_read_log_seg( if (recv_recovery_is_on() && recv_sys && recv_sys->report(ut_time())) { ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF, start_lsn); - sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF, - start_lsn); + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Read redo log up to LSN=" LSN_PF, + start_lsn); } if (start_lsn != end_lsn) { @@ -3553,7 +3560,9 @@ logs_empty_and_mark_files_at_shutdown(void) os_event_set(lock_sys->timeout_event); os_event_set(dict_stats_event); } - os_thread_sleep(100000); +#define COUNT_INTERVAL 600U +#define CHECK_INTERVAL 100000U + os_thread_sleep(CHECK_INTERVAL); count++; @@ -3565,7 +3574,11 @@ logs_empty_and_mark_files_at_shutdown(void) if (ulint total_trx = srv_was_started && !srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO ? trx_sys_any_active_transactions() : 0) { - if (srv_print_verbose_log && count > 600) { + if (srv_print_verbose_log && count > COUNT_INTERVAL) { + service_manager_extend_timeout( + COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for %lu active transactions to finish", + (ulong) total_trx); ib_logf(IB_LOG_LEVEL_INFO, "Waiting for %lu active transactions to finish", (ulong) total_trx); @@ -3600,7 +3613,10 @@ logs_empty_and_mark_files_at_shutdown(void) if (thread_name) { ut_ad(!srv_read_only_mode); wait_suspend_loop: - if (srv_print_verbose_log && count > 600) { + service_manager_extend_timeout( + COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for %s to exit", thread_name); + if (srv_print_verbose_log && count > COUNT_INTERVAL) { ib_logf(IB_LOG_LEVEL_INFO, "Waiting for %s to exit", thread_name); count = 0; @@ -3636,6 +3652,8 @@ logs_empty_and_mark_files_at_shutdown(void) before proceeding further. */ count = 0; + service_manager_extend_timeout(COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for page cleaner"); os_rmb; while (buf_page_cleaner_is_active || buf_lru_manager_is_active) { if (srv_print_verbose_log && count == 0) { @@ -3644,8 +3662,10 @@ logs_empty_and_mark_files_at_shutdown(void) "finish flushing of buffer pool"); } ++count; - os_thread_sleep(100000); - if (count > 600) { + os_thread_sleep(CHECK_INTERVAL); + if (srv_print_verbose_log && count > COUNT_INTERVAL) { + service_manager_extend_timeout(COUNT_INTERVAL * CHECK_INTERVAL/1000000 * 2, + "Waiting for page cleaner"); count = 0; } os_rmb; @@ -3730,6 +3750,8 @@ logs_empty_and_mark_files_at_shutdown(void) } if (!srv_read_only_mode) { + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "ensuring dirty buffer pool are written to log"); log_make_checkpoint_at(LSN_MAX, TRUE); mutex_enter(&log_sys->mutex); @@ -3758,23 +3780,9 @@ logs_empty_and_mark_files_at_shutdown(void) mutex_exit(&log_sys->mutex); - fil_flush_file_spaces(FIL_TABLESPACE); + /* Ensure that all buffered changes are written to the + redo log before fil_close_all_files(). */ fil_flush_file_spaces(FIL_LOG); - - /* The call fil_write_flushed_lsn_to_data_files() will - bypass the buffer pool: therefore it is essential that - the buffer pool has been completely flushed to disk! */ - - if (!buf_all_freed()) { - if (srv_print_verbose_log && count > 600) { - ib_logf(IB_LOG_LEVEL_INFO, - "Waiting for dirty buffer pages" - " to be flushed"); - count = 0; - } - - goto loop; - } } else { lsn = srv_start_lsn; } @@ -3791,8 +3799,9 @@ logs_empty_and_mark_files_at_shutdown(void) srv_thread_type type = srv_get_active_thread_type(); ut_a(type == SRV_NONE); - bool freed = buf_all_freed(); - ut_a(freed); + service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, + "Free innodb buffer pool"); + buf_all_freed(); ut_a(lsn == log_sys->lsn); ut_ad(srv_force_recovery >= SRV_FORCE_NO_LOG_REDO @@ -3824,9 +3833,6 @@ logs_empty_and_mark_files_at_shutdown(void) type = srv_get_active_thread_type(); ut_a(type == SRV_NONE); - freed = buf_all_freed(); - ut_a(freed); - ut_a(lsn == log_sys->lsn); } diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index 1943fb51f37ecda833449bcc756c9234826447c3..d8e90de45e9f9180ad0264b51db47593fdbe3d61 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -30,7 +30,7 @@ Created 9/20/1997 Heikki Tuuri #include // Solaris/x86 header file bug #include -#include +#include #include "log0recv.h" @@ -1804,8 +1804,8 @@ recv_recover_page_func( if (recv_sys->report(time)) { ib_logf(IB_LOG_LEVEL_INFO, "To recover: " ULINTPF " pages from log", n); - sd_notifyf(0, "STATUS=To recover: " ULINTPF - " pages from log", n); + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, "To recover: " ULINTPF " pages from log", n); } } @@ -3001,6 +3001,9 @@ recv_init_crash_recovery(void) and restore them from the doublewrite buffer if possible */ + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, "Starting Innodb crash recovery"); + if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { buf_dblwr_process(); diff --git a/storage/xtradb/mem/mem0mem.cc b/storage/xtradb/mem/mem0mem.cc index b9f190509eebb549a5e9c3302be21928990953de..f91126697fc71683a12a1b7145a577355037aab7 100644 --- a/storage/xtradb/mem/mem0mem.cc +++ b/storage/xtradb/mem/mem0mem.cc @@ -406,6 +406,11 @@ mem_heap_create_block_func( heap->total_size += len; } + /* Poison all available memory. Individual chunks will be unpoisoned on + every mem_heap_alloc() call. */ + compile_time_assert(MEM_BLOCK_HEADER_SIZE >= sizeof *block); + UNIV_MEM_FREE(block + 1, len - sizeof *block); + ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len); return(block); diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 634ebb2af4956689a978e6dbefcc4164ca4ce3ac..2e172a7524c44cf42d015861efd9e49ace38e03c 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -1437,7 +1437,8 @@ os_file_create_simple_func( /* Use default security attributes and no template file. */ file = CreateFile( - (LPCTSTR) name, access, FILE_SHARE_READ, NULL, + (LPCTSTR) name, access, + FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, create_flag, attributes, NULL); if (file == INVALID_HANDLE_VALUE) { @@ -1508,7 +1509,7 @@ os_file_create_simple_func( } do { - file = ::open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC, os_innodb_umask); if (file == -1) { *success = FALSE; @@ -1603,7 +1604,7 @@ os_file_create_simple_no_error_handling_func( DWORD access; DWORD create_flag; DWORD attributes = 0; - DWORD share_mode = FILE_SHARE_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE; ut_a(name); ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); @@ -1730,7 +1731,7 @@ os_file_create_simple_no_error_handling_func( return(file); } - file = open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC , os_innodb_umask); *success = file != -1; @@ -1925,7 +1926,7 @@ os_file_create_func( #ifdef __WIN__ DWORD create_flag; - DWORD share_mode = FILE_SHARE_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE; on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT ? TRUE : FALSE; @@ -2145,7 +2146,7 @@ os_file_create_func( #endif /* O_SYNC */ do { - file = open(name, create_flag, os_innodb_umask); + file = ::open(name, create_flag | O_CLOEXEC, os_innodb_umask); if (file == -1) { const char* operation; @@ -2358,6 +2359,24 @@ os_file_delete_func( #endif } +/** Handle RENAME error. +@param name old name of the file +@param new_name new name of the file */ +static void os_file_handle_rename_error(const char* name, const char* new_name) +{ + if (os_file_get_last_error(true) != OS_FILE_DISK_FULL) { + ib_logf(IB_LOG_LEVEL_ERROR, "Cannot rename file '%s' to '%s'", + name, new_name); + } else if (!os_has_said_disk_full) { + os_has_said_disk_full = true; + /* Disk full error is reported irrespective of the + on_error_silent setting. */ + ib_logf(IB_LOG_LEVEL_ERROR, + "Full disk prevents renaming file '%s' to '%s'", + name, new_name); + } +} + /***********************************************************************//** NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can also move it to another directory). It is safest that the @@ -2393,7 +2412,7 @@ os_file_rename_func( return(TRUE); } - os_file_handle_error_no_exit(oldpath, "rename", FALSE, __FILE__, __LINE__); + os_file_handle_rename_error(oldpath, newpath); return(FALSE); #else @@ -2403,7 +2422,7 @@ os_file_rename_func( ret = rename(oldpath, newpath); if (ret != 0) { - os_file_handle_error_no_exit(oldpath, "rename", FALSE, __FILE__, __LINE__); + os_file_handle_rename_error(oldpath, newpath); return(FALSE); } @@ -3169,15 +3188,21 @@ os_file_read_func( overlapped.hEvent = win_get_syncio_event(); ret = ReadFile(file, buf, n, NULL, &overlapped); if (ret) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, FALSE); - } - else if(GetLastError() == ERROR_IO_PENDING) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); + ret = GetOverlappedResult(file, &overlapped, &len, FALSE); + } else if (GetLastError() == ERROR_IO_PENDING) { + ret = GetOverlappedResult(file, &overlapped, &len, TRUE); } MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); - if (ret && len == n) { + if (!ret) { + } else if (len == n) { return(TRUE); + } else { + ib_logf(IB_LOG_LEVEL_ERROR, + "Tried to read " ULINTPF " bytes at offset " + UINT64PF ". Was only able to read %lu.", + n, offset, ret); + return FALSE; } #else /* __WIN__ */ ibool retry; @@ -3204,6 +3229,7 @@ os_file_read_func( "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", n, offset, (lint) ret); + return FALSE; } #endif /* __WIN__ */ retry = os_file_handle_error(NULL, "read", __FILE__, __LINE__); @@ -3272,15 +3298,21 @@ os_file_read_no_error_handling_func( overlapped.hEvent = win_get_syncio_event(); ret = ReadFile(file, buf, n, NULL, &overlapped); if (ret) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, FALSE); - } - else if(GetLastError() == ERROR_IO_PENDING) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); + ret = GetOverlappedResult(file, &overlapped, &len, FALSE); + } else if (GetLastError() == ERROR_IO_PENDING) { + ret = GetOverlappedResult(file, &overlapped, &len, TRUE); } MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_READS, monitor); - if (ret && len == n) { + if (!ret) { + } else if (len == n) { return(TRUE); + } else { + ib_logf(IB_LOG_LEVEL_ERROR, + "Tried to read " ULINTPF " bytes at offset " + UINT64PF ". Was only able to read %lu.", + n, offset, len); + return FALSE; } #else /* __WIN__ */ ibool retry; @@ -3303,6 +3335,7 @@ os_file_read_no_error_handling_func( "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", n, offset, (lint) ret); + return FALSE; } #endif /* __WIN__ */ retry = os_file_handle_error_no_exit(NULL, "read", FALSE, __FILE__, __LINE__); @@ -3383,10 +3416,9 @@ os_file_write_func( overlapped.hEvent = win_get_syncio_event(); ret = WriteFile(file, buf, n, NULL, &overlapped); if (ret) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, FALSE); - } - else if ( GetLastError() == ERROR_IO_PENDING) { - ret = GetOverlappedResult(file, &overlapped, (DWORD *)&len, TRUE); + ret = GetOverlappedResult(file, &overlapped, &len, FALSE); + } else if (GetLastError() == ERROR_IO_PENDING) { + ret = GetOverlappedResult(file, &overlapped, &len, TRUE); } MONITOR_ATOMIC_DEC_LOW(MONITOR_OS_PENDING_WRITES, monitor); @@ -3704,7 +3736,7 @@ os_file_get_status( access = !srv_read_only_mode ? O_RDWR : O_RDONLY; - fh = ::open(path, access, os_innodb_umask); + fh = ::open(path, access | O_CLOEXEC, os_innodb_umask); if (fh == -1) { stat_info->rw_perm = false; @@ -4133,7 +4165,7 @@ os_aio_native_aio_supported(void) strcpy(name + dirnamelen, "ib_logfile0"); - fd = ::open(name, O_RDONLY); + fd = ::open(name, O_RDONLY | O_CLOEXEC); if (fd == -1) { @@ -6588,8 +6620,7 @@ os_file_trim( DWORD tmp; if (ret) { ret = GetOverlappedResult(slot->file, &overlapped, &tmp, FALSE); - } - else if (GetLastError() == ERROR_IO_PENDING) { + } else if (GetLastError() == ERROR_IO_PENDING) { ret = GetOverlappedResult(slot->file, &overlapped, &tmp, TRUE); } if (!ret) { diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc index fc93eebd445654297e3261f92d84bb5680bc1129..e21880c2d4b556c00bd0da1a6784b700aa01bf60 100644 --- a/storage/xtradb/page/page0page.cc +++ b/storage/xtradb/page/page0page.cc @@ -2,6 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2018, 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 @@ -98,17 +99,13 @@ page_dir_find_owner_slot( /*=====================*/ const rec_t* rec) /*!< in: the physical record */ { - const page_t* page; - register uint16 rec_offs_bytes; - register const page_dir_slot_t* slot; - register const page_dir_slot_t* first_slot; - register const rec_t* r = rec; - ut_ad(page_rec_check(rec)); - page = page_align(rec); - first_slot = page_dir_get_nth_slot(page, 0); - slot = page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1); + const page_t* page = page_align(rec); + const page_dir_slot_t* first_slot = page_dir_get_nth_slot(page, 0); + const page_dir_slot_t* slot = page_dir_get_nth_slot( + page, page_dir_get_n_slots(page) - 1); + const rec_t* r = rec; if (page_is_comp(page)) { while (rec_get_n_owned_new(r) == 0) { @@ -124,7 +121,7 @@ page_dir_find_owner_slot( } } - rec_offs_bytes = mach_encode_2(r - page); + uint16 rec_offs_bytes = mach_encode_2(r - page); while (UNIV_LIKELY(*(uint16*) slot != rec_offs_bytes)) { diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc index f0035302852c4d7968c826fa267028864be61500..4af409535672fe0452f3a997f6ebff8465fcc887 100644 --- a/storage/xtradb/row/row0import.cc +++ b/storage/xtradb/row/row0import.cc @@ -31,6 +31,7 @@ Created 2012-02-08 by Sunny Bains. #endif #include "btr0pcur.h" +#include "btr0sea.h" #include "que0que.h" #include "dict0boot.h" #include "ibuf0ibuf.h" @@ -40,13 +41,17 @@ Created 2012-02-08 by Sunny Bains. #include "row0mysql.h" #include "srv0start.h" #include "row0quiesce.h" -#include "buf0buf.h" +#include "fil0pagecompress.h" +#ifdef HAVE_LZO +#include "lzo/lzo1x.h" +#endif +#ifdef HAVE_SNAPPY +#include "snappy-c.h" +#endif #include -/** The size of the buffer to use for IO. Note: os_file_read() doesn't expect -reads to fail. If you set the buffer size to be greater than a multiple of the -file size then it will assert. TODO: Fix this limitation of the IO functions. +/** The size of the buffer to use for IO. @param n - page size of the tablespace. @retval number of pages */ #define IO_BUFFER_SIZE(n) ((1024 * 1024) / n) @@ -362,7 +367,8 @@ class IndexPurge { /** Functor that is called for each physical page that is read from the tablespace file. */ -class AbstractCallback : public PageCallback { +class AbstractCallback +{ public: /** Constructor @param trx - covering transaction */ @@ -395,32 +401,59 @@ class AbstractCallback : public PageCallback { return(get_zip_size() > 0); } -protected: /** - Get the data page depending on the table type, compressed or not. - @param block - block read from disk - @retval the buffer frame */ - buf_frame_t* get_frame(buf_block_t* block) const UNIV_NOTHROW + Set the name of the physical file and the file handle that is used + to open it for the file that is being iterated over. + @param filename - then physical name of the tablespace file. + @param file - OS file handle */ + void set_file(const char* filename, pfs_os_file_t file) UNIV_NOTHROW { - if (is_compressed_table()) { - return(block->page.zip.data); - } + m_file = file; + m_filepath = filename; + } - return(buf_block_get_frame(block)); + /** The compressed page size + @return the compressed page size */ + ulint get_zip_size() const + { + return(m_zip_size); } - /** Check for session interrupt. If required we could - even flush to disk here every N pages. - @retval DB_SUCCESS or error code */ - dberr_t periodic_check() UNIV_NOTHROW + /** The compressed page size + @return the compressed page size */ + ulint get_page_size() const { - if (trx_is_interrupted(m_trx)) { - return(DB_INTERRUPTED); - } + return(m_page_size); + } - return(DB_SUCCESS); + const char* filename() const { return m_filepath; } + + /** + Called for every page in the tablespace. If the page was not + updated then its state must be set to BUF_PAGE_NOT_USED. For + compressed tables the page descriptor memory will be at offset: + block->frame + UNIV_PAGE_SIZE; + @param block block read from file, note it is not from the buffer pool + @retval DB_SUCCESS or error code. */ + virtual dberr_t operator()(buf_block_t* block) UNIV_NOTHROW = 0; + + /** + @return the space id of the tablespace */ + virtual ulint get_space_id() const UNIV_NOTHROW = 0; + + bool is_interrupted() const { return trx_is_interrupted(m_trx); } + + /** + Get the data page depending on the table type, compressed or not. + @param block - block read from disk + @retval the buffer frame */ + static byte* get_frame(const buf_block_t* block) + { + return block->page.zip.data + ? block->page.zip.data : block->frame; } +protected: /** Get the physical offset of the extent descriptor within the page. @param page_no - page number of the extent descriptor @@ -510,6 +543,18 @@ class AbstractCallback : public PageCallback { } protected: + /** Compressed table page size */ + ulint m_zip_size; + + /** The tablespace page size. */ + ulint m_page_size; + + /** File handle to the tablespace */ + pfs_os_file_t m_file; + + /** Physical file path. */ + const char* m_filepath; + /** Covering transaction. */ trx_t* m_trx; @@ -566,9 +611,9 @@ AbstractCallback::init( /* Since we don't know whether it is a compressed table or not, the data is always read into the block->frame. */ - dberr_t err = set_zip_size(block->frame); + m_zip_size = fsp_header_get_zip_size(page); - if (err != DB_SUCCESS) { + if (!ut_is_2pow(m_zip_size) || m_zip_size > UNIV_ZIP_SIZE_MAX) { return(DB_CORRUPTION); } @@ -605,11 +650,7 @@ AbstractCallback::init( m_free_limit = mach_read_from_4(page + FSP_FREE_LIMIT); m_space = mach_read_from_4(page + FSP_HEADER_OFFSET + FSP_SPACE_ID); - if ((err = set_current_xdes(0, page)) != DB_SUCCESS) { - return(err); - } - - return(DB_SUCCESS); + return set_current_xdes(0, page); } /** @@ -651,12 +692,9 @@ struct FetchIndexRootPages : public AbstractCallback { /** Called for each block as it is read from the file. - @param offset - physical offset in the file - @param block - block to convert, it is not from the buffer pool. + @param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ - virtual dberr_t operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW; + dberr_t operator()(buf_block_t* block) UNIV_NOTHROW; /** Update the import configuration that will be used to import the tablespace. */ @@ -674,34 +712,18 @@ Called for each block as it is read from the file. Check index pages to determine the exact row format. We can't get that from the tablespace header flags alone. -@param offset - physical offset in the file -@param block - block to convert, it is not from the buffer pool. +@param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ -dberr_t -FetchIndexRootPages::operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW +dberr_t FetchIndexRootPages::operator()(buf_block_t* block) UNIV_NOTHROW { - dberr_t err; - - if ((err = periodic_check()) != DB_SUCCESS) { - return(err); - } + if (is_interrupted()) return DB_INTERRUPTED; const page_t* page = get_frame(block); ulint page_type = fil_page_get_type(page); - if (block->page.offset * m_page_size != offset) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Page offset doesn't match file offset: " - "page offset: %u, file offset: " ULINTPF, - block->page.offset, - (ulint) (offset / m_page_size)); - - err = DB_CORRUPTION; - } else if (page_type == FIL_PAGE_TYPE_XDES) { - err = set_current_xdes(block->page.offset, page); + if (page_type == FIL_PAGE_TYPE_XDES) { + return set_current_xdes(block->page.offset, page); } else if (page_type == FIL_PAGE_INDEX && !is_free(block->page.offset) && is_root_page(page)) { @@ -726,7 +748,7 @@ FetchIndexRootPages::operator() ( } } - return(err); + return DB_SUCCESS; } /** @@ -843,21 +865,10 @@ class PageConverter : public AbstractCallback { /** Called for each block as it is read from the file. - @param offset - physical offset in the file - @param block - block to convert, it is not from the buffer pool. + @param block block to convert, it is not from the buffer pool. @retval DB_SUCCESS or error code. */ - virtual dberr_t operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW; + dberr_t operator()(buf_block_t* block) UNIV_NOTHROW; private: - - /** Status returned by PageConverter::validate() */ - enum import_page_status_t { - IMPORT_PAGE_STATUS_OK, /*!< Page is OK */ - IMPORT_PAGE_STATUS_ALL_ZERO, /*!< Page is all zeros */ - IMPORT_PAGE_STATUS_CORRUPTED /*!< Page is corrupted */ - }; - /** Update the page, set the space id, max trx id and index id. @param block - block read from file @@ -867,17 +878,6 @@ class PageConverter : public AbstractCallback { buf_block_t* block, ulint& page_type) UNIV_NOTHROW; -#if defined UNIV_DEBUG - /** - @return true error condition is enabled. */ - bool trigger_corruption() UNIV_NOTHROW - { - return(false); - } - #else -#define trigger_corruption() (false) -#endif /* UNIV_DEBUG */ - /** Update the space, index id, trx id. @param block - block to convert @@ -890,15 +890,6 @@ class PageConverter : public AbstractCallback { @retval DB_SUCCESS or error code */ dberr_t update_records(buf_block_t* block) UNIV_NOTHROW; - /** - Validate the page, check for corruption. - @param offset - physical offset within file. - @param page - page read from file. - @return 0 on success, 1 if all zero, 2 if corrupted */ - import_page_status_t validate( - os_offset_t offset, - buf_block_t* page) UNIV_NOTHROW; - /** Validate the space flags and update tablespace header page. @param block - block read from file, not from the buffer pool. @@ -1316,8 +1307,8 @@ row_import::match_schema( return(DB_ERROR); } else if (m_table->n_cols != m_n_cols) { ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH, - "Number of columns don't match, table has %u " - "columns but the tablespace meta-data file has " + "Number of columns don't match, table has %u" + " columns but the tablespace meta-data file has " ULINTPF " columns", m_table->n_cols, m_n_cols); @@ -1597,6 +1588,7 @@ IndexPurge::purge() UNIV_NOTHROW Constructor * @param cfg - config of table being imported. * @param trx - transaction covering the import */ +inline PageConverter::PageConverter( row_import* cfg, trx_t* trx) @@ -1621,6 +1613,7 @@ Adjust the BLOB reference for a single column that is externally stored @param offsets - column offsets for the record @param i - column ordinal value @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_column( rec_t* rec, @@ -1673,6 +1666,7 @@ stored columns. @param rec - record to update @param offsets - column offsets for the record @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_columns( rec_t* rec, @@ -1706,6 +1700,7 @@ BLOB reference, write the new space id. @param rec - record to update @param offsets - column offsets for the record @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::adjust_cluster_index_blob_ref( rec_t* rec, @@ -1729,6 +1724,7 @@ Purge delete-marked records, only if it is possible to do so without re-organising the B+tree. @param offsets - current row offsets. @return true if purge succeeded */ +inline bool PageConverter::purge(const ulint* offsets) UNIV_NOTHROW { @@ -1753,6 +1749,7 @@ Adjust the BLOB references and sys fields for the current record. @param offsets - column offsets for the record @param deleted - true if row is delete marked @return DB_SUCCESS or error code. */ +inline dberr_t PageConverter::adjust_cluster_record( const dict_index_t* index, @@ -1770,7 +1767,7 @@ PageConverter::adjust_cluster_record( row_upd_rec_sys_fields( rec, m_page_zip_ptr, m_cluster_index, m_offsets, - m_trx, 0); + m_trx, roll_ptr_t(1) << 55); } return(err); @@ -1781,6 +1778,7 @@ Update the BLOB refrences and write UNDO log entries for rows that can't be purged optimistically. @param block - block to update @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_records( buf_block_t* block) UNIV_NOTHROW @@ -1792,10 +1790,6 @@ PageConverter::update_records( m_rec_iter.open(block); - if (!page_is_leaf(block->frame)) { - return DB_SUCCESS; - } - while (!m_rec_iter.end()) { rec_t* rec = m_rec_iter.current(); ibool deleted = rec_get_deleted_flag(rec, comp); @@ -1846,6 +1840,7 @@ PageConverter::update_records( /** Update the space, index id, trx id. @return DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_index_page( buf_block_t* block) UNIV_NOTHROW @@ -1908,13 +1903,14 @@ PageConverter::update_index_page( return(DB_SUCCESS); } - return(update_records(block)); + return page_is_leaf(block->frame) ? update_records(block) : DB_SUCCESS; } /** Validate the space flags and update tablespace header page. @param block - block read from file, not from the buffer pool. @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_header( buf_block_t* block) UNIV_NOTHROW @@ -1954,6 +1950,7 @@ PageConverter::update_header( Update the page, set the space id, max trx id and index id. @param block - block read from file @retval DB_SUCCESS or error code */ +inline dberr_t PageConverter::update_page( buf_block_t* block, @@ -1961,6 +1958,14 @@ PageConverter::update_page( { dberr_t err = DB_SUCCESS; + ut_ad(!block->page.zip.data == !is_compressed_table()); + + if (block->page.zip.data) { + m_page_zip_ptr = &block->page.zip; + } else { + ut_ad(!m_page_zip_ptr); + } + switch (page_type = fil_page_get_type(get_frame(block))) { case FIL_PAGE_TYPE_FSP_HDR: /* Work directly on the uncompressed page headers. */ @@ -2015,141 +2020,45 @@ PageConverter::update_page( return(DB_CORRUPTION); } -/** -Validate the page -@param offset - physical offset within file. -@param page - page read from file. -@return status */ -PageConverter::import_page_status_t -PageConverter::validate( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW -{ - buf_frame_t* page = get_frame(block); - - /* Check that the page number corresponds to the offset in - the file. Flag as corrupt if it doesn't. Disable the check - for LSN in buf_page_is_corrupted() */ - - if (buf_page_is_corrupted(false, page, get_zip_size(), NULL) - || (page_get_page_no(page) != offset / m_page_size - && page_get_page_no(page) != 0)) { - - return(IMPORT_PAGE_STATUS_CORRUPTED); - - } else if (offset > 0 && page_get_page_no(page) == 0) { - ulint checksum; - - checksum = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM); - if (checksum != 0) { - /* Checksum check passed in buf_page_is_corrupted(). */ - ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu checksum " ULINTPF - " should be zero.", - m_filepath, (ulong) (offset / m_page_size), - checksum); - } - - const byte* b = page + FIL_PAGE_OFFSET; - const byte* e = page + m_page_size - - FIL_PAGE_END_LSN_OLD_CHKSUM; - - /* If the page number is zero and offset > 0 then - the entire page MUST consist of zeroes. If not then - we flag it as corrupt. */ - - while (b != e) { - - if (*b++ && !trigger_corruption()) { - return(IMPORT_PAGE_STATUS_CORRUPTED); - } - } - - /* The page is all zero: do nothing. */ - return(IMPORT_PAGE_STATUS_ALL_ZERO); - } - - return(IMPORT_PAGE_STATUS_OK); -} - /** Called for every page in the tablespace. If the page was not updated then its state must be set to BUF_PAGE_NOT_USED. -@param offset - physical offset within the file -@param block - block read from file, note it is not from the buffer pool +@param block block read from file, note it is not from the buffer pool @retval DB_SUCCESS or error code. */ -dberr_t -PageConverter::operator() ( - os_offset_t offset, - buf_block_t* block) UNIV_NOTHROW +dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW { - ulint page_type; - dberr_t err = DB_SUCCESS; - - if ((err = periodic_check()) != DB_SUCCESS) { - return(err); - } - - if (is_compressed_table()) { - m_page_zip_ptr = &block->page.zip; - } else { - ut_ad(m_page_zip_ptr == 0); - } - - switch(validate(offset, block)) { - case IMPORT_PAGE_STATUS_OK: - - /* We have to decompress the compressed pages before - we can work on them */ - - if ((err = update_page(block, page_type)) != DB_SUCCESS) { - break; - } - - /* Note: For compressed pages this function will write to the - zip descriptor and for uncompressed pages it will write to - page (ie. the block->frame). Therefore the caller should write - out the descriptor contents and not block->frame for compressed - pages. */ - - if (!is_compressed_table() || page_type == FIL_PAGE_INDEX) { - - buf_flush_init_for_writing( - !is_compressed_table() - ? block->frame : block->page.zip.data, - !is_compressed_table() ? 0 : m_page_zip_ptr, - m_current_lsn); - } else { - /* Calculate and update the checksum of non-btree - pages for compressed tables explicitly here. */ - - buf_flush_update_zip_checksum( - get_frame(block), get_zip_size(), - m_current_lsn); - } - - break; + /* If we already had an old page with matching number + in the buffer pool, evict it now, because + we no longer evict the pages on DISCARD TABLESPACE. */ + buf_page_get_gen(get_space_id(), get_zip_size(), block->page.offset, + RW_NO_LATCH, NULL, BUF_EVICT_IF_IN_POOL, + __FILE__, __LINE__, NULL); - case IMPORT_PAGE_STATUS_ALL_ZERO: - /* The page is all zero: leave it as is. */ - break; + ulint page_type; - case IMPORT_PAGE_STATUS_CORRUPTED: + dberr_t err = update_page(block, page_type); + if (err != DB_SUCCESS) return err; - ib_logf(IB_LOG_LEVEL_WARN, - "%s: Page %lu at offset " UINT64PF " looks corrupted.", - m_filepath, (ulong) (offset / m_page_size), offset); + /* Note: For compressed pages this function will write to the + zip descriptor and for uncompressed pages it will write to + page (ie. the block->frame). Therefore the caller should write + out the descriptor contents and not block->frame for compressed + pages. */ - err = DB_CORRUPTION; + if (!is_compressed_table() || page_type == FIL_PAGE_INDEX) { + buf_flush_init_for_writing( + get_frame(block), + block->page.zip.data ? &block->page.zip : NULL, + m_current_lsn); + } else { + /* Calculate and update the checksum of non-btree + pages for compressed tables explicitly here. */ + buf_flush_update_zip_checksum( + get_frame(block), get_zip_size(), + m_current_lsn); } - /* If we already had and old page with matching number - in the buffer pool, evict it now, because - we no longer evict the pages on DISCARD TABLESPACE. */ - buf_page_get_gen(get_space_id(), get_zip_size(), block->page.offset, - RW_NO_LATCH, NULL, BUF_EVICT_IF_IN_POOL, - __FILE__, __LINE__, NULL); - return(err); + return DB_SUCCESS; } /*****************************************************************//** @@ -3424,6 +3333,498 @@ row_import_update_discarded_flag( return(err); } +struct fil_iterator_t { + pfs_os_file_t file; /*!< File handle */ + const char* filepath; /*!< File path name */ + os_offset_t start; /*!< From where to start */ + os_offset_t end; /*!< Where to stop */ + os_offset_t file_size; /*!< File size in bytes */ + ulint page_size; /*!< Page size */ + ulint n_io_buffers; /*!< Number of pages to use + for IO */ + byte* io_buffer; /*!< Buffer to use for IO */ + fil_space_crypt_t *crypt_data; /*!< Crypt data (if encrypted) */ + byte* crypt_io_buffer; /*!< IO buffer when encrypted */ +}; + +/********************************************************************//** +TODO: This can be made parallel trivially by chunking up the file and creating +a callback per thread. . Main benefit will be to use multiple CPUs for +checksums and compressed tables. We have to do compressed tables block by +block right now. Secondly we need to decompress/compress and copy too much +of data. These are CPU intensive. + +Iterate over all the pages in the tablespace. +@param iter - Tablespace iterator +@param block - block to use for IO +@param callback - Callback to inspect and update page contents +@retval DB_SUCCESS or error code */ +static +dberr_t +fil_iterate( +/*========*/ + const fil_iterator_t& iter, + buf_block_t* block, + AbstractCallback& callback) +{ + os_offset_t offset; + ulint n_bytes = iter.n_io_buffers * iter.page_size; + + const ulint buf_size = srv_page_size +#ifdef HAVE_LZO + + LZO1X_1_15_MEM_COMPRESS +#elif defined HAVE_SNAPPY + + snappy_max_compressed_length(srv_page_size) +#endif + ; + byte* page_compress_buf = static_cast( + ut_malloc_low(buf_size, false)); + ut_ad(!srv_read_only_mode); + + if (!page_compress_buf) { + return DB_OUT_OF_MEMORY; + } + + /* TODO: For ROW_FORMAT=COMPRESSED tables we do a lot of useless + copying for non-index pages. Unfortunately, it is + required by buf_zip_decompress() */ + dberr_t err = DB_SUCCESS; + + for (offset = iter.start; offset < iter.end; offset += n_bytes) { + if (callback.is_interrupted()) { + err = DB_INTERRUPTED; + goto func_exit; + } + + byte* io_buffer = iter.io_buffer; + block->frame = io_buffer; + + if (block->page.zip.data) { + /* Zip IO is done in the compressed page buffer. */ + io_buffer = block->page.zip.data; + ut_ad(PAGE_ZIP_MATCH(block->frame, &block->page.zip)); + } + + /* We have to read the exact number of bytes. Otherwise the + InnoDB IO functions croak on failed reads. */ + + n_bytes = ulint(ut_min(os_offset_t(n_bytes), + iter.end - offset)); + + ut_ad(n_bytes > 0); + ut_ad(!(n_bytes % iter.page_size)); + + const bool encrypted = iter.crypt_data != NULL + && iter.crypt_data->should_encrypt(); + /* Use additional crypt io buffer if tablespace is encrypted */ + byte* const readptr = encrypted + ? iter.crypt_io_buffer : io_buffer; + byte* const writeptr = readptr; + + if (!os_file_read_no_error_handling(iter.file, readptr, + offset, n_bytes)) { + ib_logf(IB_LOG_LEVEL_ERROR, "os_file_read() failed"); + err = DB_IO_ERROR; + goto func_exit; + } + + bool updated = false; + const ulint size = iter.page_size; + ulint n_pages_read = ulint(n_bytes) / size; + block->page.offset = offset / size; + + for (ulint i = 0; i < n_pages_read; + ++i, block->frame += size, block->page.offset++) { + byte* src = readptr + (i * size); + const ulint page_no = page_get_page_no(src); + if (!page_no && block->page.offset) { + const ulint* b = reinterpret_cast + (src); + const ulint* const e = b + size / sizeof *b; + do { + if (*b++) { + goto page_corrupted; + } + } while (b != e); + + /* Proceed to the next page, + because this one is all zero. */ + continue; + } + + if (page_no != block->page.offset) { +page_corrupted: + ib_logf(IB_LOG_LEVEL_WARN, + "%s: Page %lu at offset " + UINT64PF " looks corrupted.", + callback.filename(), + ulong(offset / size), offset); + err = DB_CORRUPTION; + goto func_exit; + } + + bool decrypted = false; + byte* dst = io_buffer + (i * size); + bool frame_changed = false; + ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); + const bool page_compressed + = page_type + == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED + || page_type == FIL_PAGE_PAGE_COMPRESSED; + + if (page_compressed && block->page.zip.data) { + goto page_corrupted; + } + + if (!encrypted) { + } else if (!mach_read_from_4( + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + + src)) { +not_encrypted: + if (!page_compressed + && !block->page.zip.data) { + block->frame = src; + frame_changed = true; + } else { + ut_ad(dst != src); + memcpy(dst, src, size); + } + } else { + if (!fil_space_verify_crypt_checksum( + src, callback.get_zip_size(), + NULL, block->page.offset)) { + goto page_corrupted; + } + + decrypted = fil_space_decrypt( + iter.crypt_data, dst, + iter.page_size, src, &err); + + if (err != DB_SUCCESS) { + goto func_exit; + } + + if (!decrypted) { + goto not_encrypted; + } + + updated = true; + } + + /* If the original page is page_compressed, we need + to decompress it before adjusting further. */ + if (page_compressed) { + ulint compress_length = fil_page_decompress( + page_compress_buf, dst); + ut_ad(compress_length != srv_page_size); + if (compress_length == 0) { + goto page_corrupted; + } + updated = true; + } else if (buf_page_is_corrupted( + false, + encrypted && !frame_changed + ? dst : src, + callback.get_zip_size(), NULL)) { + goto page_corrupted; + } + + if ((err = callback(block)) != DB_SUCCESS) { + goto func_exit; + } else if (!updated) { + updated = buf_block_get_state(block) + == BUF_BLOCK_FILE_PAGE; + } + + /* If tablespace is encrypted we use additional + temporary scratch area where pages are read + for decrypting readptr == crypt_io_buffer != io_buffer. + + Destination for decryption is a buffer pool block + block->frame == dst == io_buffer that is updated. + Pages that did not require decryption even when + tablespace is marked as encrypted are not copied + instead block->frame is set to src == readptr. + + For encryption we again use temporary scratch area + writeptr != io_buffer == dst + that is then written to the tablespace + + (1) For normal tables io_buffer == dst == writeptr + (2) For only page compressed tables + io_buffer == dst == writeptr + (3) For encrypted (and page compressed) + readptr != io_buffer == dst != writeptr + */ + + ut_ad(!encrypted && !page_compressed ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(page_compressed && !encrypted ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(encrypted ? + src != dst && dst != writeptr + (i * size):1); + + /* When tablespace is encrypted or compressed its + first page (i.e. page 0) is not encrypted or + compressed and there is no need to copy frame. */ + if (encrypted && block->page.offset != 0) { + byte *local_frame = callback.get_frame(block); + ut_ad((writeptr + (i * size)) != local_frame); + memcpy((writeptr + (i * size)), local_frame, size); + } + + if (frame_changed) { + block->frame = dst; + } + + src = io_buffer + (i * size); + + if (page_compressed) { + updated = true; + if (fil_page_compress( + src, + page_compress_buf, + 0,/* FIXME: compression level */ + 512,/* FIXME: proper block size */ + encrypted)) { + /* FIXME: remove memcpy() */ + memcpy(src, page_compress_buf, + srv_page_size); + } + } + + /* If tablespace is encrypted, encrypt page before we + write it back. Note that we should not encrypt the + buffer that is in buffer pool. */ + /* NOTE: At this stage of IMPORT the + buffer pool is not being used at all! */ + if (decrypted && encrypted) { + byte *dest = writeptr + (i * size); + + byte* tmp = fil_encrypt_buf( + iter.crypt_data, + callback.get_space_id(), + block->page.offset, + mach_read_from_8(src + FIL_PAGE_LSN), + src, + callback.get_zip_size(), + dest); + + if (tmp == src) { + /* TODO: remove unnecessary memcpy's */ + ut_ad(dest != src); + memcpy(dest, src, size); + } + + updated = true; + } + } + + /* A page was updated in the set, write back to disk. */ + if (updated + && !os_file_write( + iter.filepath, iter.file, writeptr, + offset, (ulint) n_bytes)) { + + ib_logf(IB_LOG_LEVEL_ERROR, "os_file_write() failed"); + err = DB_IO_ERROR; + goto func_exit; + } + } + +func_exit: + ut_free(page_compress_buf); + return err; +} + +/********************************************************************//** +Iterate over all the pages in the tablespace. +@param table - the table definiton in the server +@param n_io_buffers - number of blocks to read and write together +@param callback - functor that will do the page updates +@return DB_SUCCESS or error code */ +static +dberr_t +fil_tablespace_iterate( +/*===================*/ + dict_table_t* table, + ulint n_io_buffers, + AbstractCallback& callback) +{ + dberr_t err; + pfs_os_file_t file; + char* filepath; + + ut_a(n_io_buffers > 0); + ut_ad(!srv_read_only_mode); + + DBUG_EXECUTE_IF("ib_import_trigger_corruption_1", + return(DB_CORRUPTION);); + + if (DICT_TF_HAS_DATA_DIR(table->flags)) { + dict_get_and_save_data_dir_path(table, false); + ut_a(table->data_dir_path); + + filepath = os_file_make_remote_pathname( + table->data_dir_path, table->name, "ibd"); + } else { + filepath = fil_make_ibd_name(table->name, false); + } + + { + ibool success; + + file = os_file_create_simple_no_error_handling( + innodb_file_data_key, filepath, + OS_FILE_OPEN, OS_FILE_READ_WRITE, &success, FALSE); + + DBUG_EXECUTE_IF("fil_tablespace_iterate_failure", + { + static bool once; + + if (!once || ut_rnd_interval(0, 10) == 5) { + once = true; + success = FALSE; + os_file_close(file); + } + }); + + if (!success) { + /* The following call prints an error message */ + os_file_get_last_error(true); + + ib_logf(IB_LOG_LEVEL_ERROR, + "Trying to import a tablespace, but could not " + "open the tablespace file %s", filepath); + + mem_free(filepath); + + return(DB_TABLESPACE_NOT_FOUND); + + } else { + err = DB_SUCCESS; + } + } + + callback.set_file(filepath, file); + + os_offset_t file_size = os_file_get_size(file); + ut_a(file_size != (os_offset_t) -1); + + /* Allocate a page to read in the tablespace header, so that we + can determine the page size and zip_size (if it is compressed). + We allocate an extra page in case it is a compressed table. One + page is to ensure alignement. */ + + void* page_ptr = mem_alloc(3 * UNIV_PAGE_SIZE); + byte* page = static_cast(ut_align(page_ptr, UNIV_PAGE_SIZE)); + + /* The block we will use for every physical page */ + buf_block_t block; + + memset(&block, 0, sizeof block); + block.frame = page; + block.page.space = callback.get_space_id(); + block.page.io_fix = BUF_IO_NONE; + block.page.buf_fix_count = 1; + block.page.state = BUF_BLOCK_FILE_PAGE; + + /* Read the first page and determine the page and zip size. */ + + if (!os_file_read_no_error_handling(file, page, 0, UNIV_PAGE_SIZE)) { + + err = DB_IO_ERROR; + + } else if ((err = callback.init(file_size, &block)) == DB_SUCCESS) { + if (const ulint zip_size = callback.get_zip_size()) { + page_zip_set_size(&block.page.zip, zip_size); + /* ROW_FORMAT=COMPRESSED is not optimised for block IO + for now. We do the IMPORT page by page. */ + n_io_buffers = 1; + } + + fil_iterator_t iter; + + iter.file = file; + iter.start = 0; + iter.end = file_size; + iter.filepath = filepath; + iter.file_size = file_size; + iter.n_io_buffers = n_io_buffers; + iter.page_size = callback.get_page_size(); + + /* In MariaDB/MySQL 5.6 tablespace does not exist + during import, therefore we can't use space directly + here. */ + ulint crypt_data_offset = fsp_header_get_crypt_offset( + callback.get_zip_size()); + + /* read (optional) crypt data */ + iter.crypt_data = fil_space_read_crypt_data( + 0, page, crypt_data_offset); + + /** If tablespace is encrypted, it needs extra buffers */ + if (iter.crypt_data != NULL) { + /* decrease io buffers so that memory + * consumption doesnt double + * note: the +1 is to avoid n_io_buffers getting down to 0 */ + iter.n_io_buffers = (iter.n_io_buffers + 1) / 2; + } + + /** Add an extra page for compressed page scratch area. */ + + void* io_buffer = mem_alloc( + (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); + + iter.io_buffer = static_cast( + ut_align(io_buffer, UNIV_PAGE_SIZE)); + + void* crypt_io_buffer = NULL; + if (iter.crypt_data != NULL) { + crypt_io_buffer = mem_alloc( + (2 + iter.n_io_buffers) * UNIV_PAGE_SIZE); + iter.crypt_io_buffer = static_cast( + ut_align(crypt_io_buffer, UNIV_PAGE_SIZE)); + } + + if (block.page.zip.ssize) { + ut_ad(iter.n_io_buffers == 1); + block.frame = iter.io_buffer; + block.page.zip.data = block.frame + UNIV_PAGE_SIZE; + ut_d(block.page.zip.m_external = true); + } + + err = fil_iterate(iter, &block, callback); + + mem_free(io_buffer); + + if (crypt_io_buffer != NULL) { + mem_free(crypt_io_buffer); + iter.crypt_io_buffer = NULL; + fil_space_destroy_crypt_data(&iter.crypt_data); + } + } + + if (err == DB_SUCCESS) { + + ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk"); + + if (!os_file_flush(file)) { + ib_logf(IB_LOG_LEVEL_INFO, "os_file_flush() failed!"); + err = DB_IO_ERROR; + } else { + ib_logf(IB_LOG_LEVEL_INFO, "Sync to disk - done!"); + } + } + + os_file_close(file); + + mem_free(page_ptr); + mem_free(filepath); + + return(err); +} + /*****************************************************************//** Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary. @@ -3598,6 +3999,17 @@ row_import_for_mysql( return(row_import_cleanup(prebuilt, trx, err)); } + /* On DISCARD TABLESPACE, we did not drop any adaptive hash + index entries. If we replaced the discarded tablespace with a + smaller one here, there could still be some adaptive hash + index entries that point to cached garbage pages in the buffer + pool, because PageConverter::operator() only evicted those + pages that were replaced by the imported pages. We must + discard all remaining adaptive hash index entries, because the + adaptive hash index must be a subset of the table contents; + false positives are not tolerated. */ + buf_LRU_drop_page_hash_for_tablespace(table); + row_mysql_lock_data_dictionary(trx); /* If the table is stored in a remote tablespace, we need to diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index 040fb37ee30e814d31e639cba22b19f365e090d2..21f1a1c5974d2547c3fd5319539d672e760a552f 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -466,6 +466,8 @@ row_log_table_open( *avail = srv_sort_buf_size - log->tail.bytes; if (size > *avail) { + /* Make sure log->tail.buf is large enough */ + ut_ad(size <= sizeof log->tail.buf); return(log->tail.buf); } else { return(log->tail.block + log->tail.bytes); @@ -584,12 +586,10 @@ row_log_table_delete( { ulint old_pk_extra_size; ulint old_pk_size; - ulint ext_size = 0; ulint mrec_size; ulint avail_size; mem_heap_t* heap = NULL; const dtuple_t* old_pk; - row_ext_t* ext; ut_ad(dict_index_is_clust(index)); ut_ad(rec_offs_validate(rec, index, offsets)); @@ -670,72 +670,20 @@ row_log_table_delete( &old_pk_extra_size); ut_ad(old_pk_extra_size < 0x100); - mrec_size = 6 + old_pk_size; - - /* Log enough prefix of the BLOB unless both the - old and new table are in COMPACT or REDUNDANT format, - which store the prefix in the clustered index record. */ - if (rec_offs_any_extern(offsets) - && (dict_table_get_format(index->table) >= UNIV_FORMAT_B - || dict_table_get_format(new_table) >= UNIV_FORMAT_B)) { - - /* Build a cache of those off-page column prefixes - that are referenced by secondary indexes. It can be - that none of the off-page columns are needed. */ - row_build(ROW_COPY_DATA, index, rec, - offsets, NULL, NULL, NULL, &ext, heap); - if (ext) { - /* Log the row_ext_t, ext->ext and ext->buf */ - ext_size = ext->n_ext * ext->max_len - + sizeof(*ext) - + ext->n_ext * sizeof(ulint) - + (ext->n_ext - 1) * sizeof ext->len; - mrec_size += ext_size; - } - } + /* 2 = 1 (extra_size) + at least 1 byte payload */ + mrec_size = 2 + old_pk_size; if (byte* b = row_log_table_open(index->online_log, mrec_size, &avail_size)) { *b++ = ROW_T_DELETE; *b++ = static_cast(old_pk_extra_size); - /* Log the size of external prefix we saved */ - mach_write_to_4(b, ext_size); - b += 4; - rec_convert_dtuple_to_temp( b + old_pk_extra_size, new_index, old_pk->fields, old_pk->n_fields); b += old_pk_size; - if (ext_size) { - ulint cur_ext_size = sizeof(*ext) - + (ext->n_ext - 1) * sizeof ext->len; - - memcpy(b, ext, cur_ext_size); - b += cur_ext_size; - - /* Check if we need to col_map to adjust the column - number. If columns were added/removed/reordered, - adjust the column number. */ - if (const ulint* col_map = - index->online_log->col_map) { - for (ulint i = 0; i < ext->n_ext; i++) { - const_cast(ext->ext[i]) = - col_map[ext->ext[i]]; - } - } - - memcpy(b, ext->ext, ext->n_ext * sizeof(*ext->ext)); - b += ext->n_ext * sizeof(*ext->ext); - - ext_size -= cur_ext_size - + ext->n_ext * sizeof(*ext->ext); - memcpy(b, ext->buf, ext_size); - b += ext_size; - } - row_log_table_close(index, b, mrec_size, avail_size); } @@ -1654,15 +1602,13 @@ row_log_table_apply_insert( /******************************************************//** Deletes a record from a table that is being rebuilt. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull(1, 2, 4, 5), warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_delete_low( /*===========================*/ btr_pcur_t* pcur, /*!< in/out: B-tree cursor, will be trashed */ const ulint* offsets, /*!< in: offsets on pcur */ - const row_ext_t* save_ext, /*!< in: saved external field - info, or NULL */ mem_heap_t* heap, /*!< in/out: memory heap */ mtr_t* mtr) /*!< in/out: mini-transaction, will be committed */ @@ -1686,11 +1632,7 @@ row_log_table_apply_delete_low( /* Build a row template for purging secondary index entries. */ row = row_build( ROW_COPY_DATA, index, btr_pcur_get_rec(pcur), - offsets, NULL, NULL, NULL, - save_ext ? NULL : &ext, heap); - if (!save_ext) { - save_ext = ext; - } + offsets, NULL, NULL, NULL, &ext, heap); } else { row = NULL; } @@ -1709,7 +1651,7 @@ row_log_table_apply_delete_low( } const dtuple_t* entry = row_build_index_entry( - row, save_ext, index, heap); + row, ext, index, heap); mtr_start(mtr); btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, pcur, mtr); @@ -1752,11 +1694,10 @@ row_log_table_apply_delete_low( /******************************************************//** Replays a delete operation on a table that was rebuilt. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull(1, 3, 4, 5, 6, 7), warn_unused_result)) +static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_log_table_apply_delete( /*=======================*/ - que_thr_t* thr, /*!< in: query graph */ ulint trx_id_col, /*!< in: position of DB_TRX_ID in the new clustered index */ @@ -1765,9 +1706,7 @@ row_log_table_apply_delete( mem_heap_t* offsets_heap, /*!< in/out: memory heap that can be emptied */ mem_heap_t* heap, /*!< in/out: memory heap */ - const row_log_t* log, /*!< in: online log */ - const row_ext_t* save_ext) /*!< in: saved external field - info, or NULL */ + const row_log_t* log) /*!< in: online log */ { dict_table_t* new_table = log->table; dict_index_t* index = dict_table_get_first_index(new_table); @@ -1867,8 +1806,7 @@ row_log_table_apply_delete( } } - return(row_log_table_apply_delete_low(&pcur, offsets, save_ext, - heap, &mtr)); + return row_log_table_apply_delete_low(&pcur, offsets, heap, &mtr); } /******************************************************//** @@ -2079,7 +2017,7 @@ row_log_table_apply_update( /* Some BLOBs are missing, so we are interpreting this ROW_T_UPDATE as ROW_T_DELETE (see *1). */ error = row_log_table_apply_delete_low( - &pcur, cur_offsets, NULL, heap, &mtr); + &pcur, cur_offsets, heap, &mtr); goto func_exit_committed; } @@ -2117,7 +2055,7 @@ row_log_table_apply_update( } error = row_log_table_apply_delete_low( - &pcur, cur_offsets, NULL, heap, &mtr); + &pcur, cur_offsets, heap, &mtr); ut_ad(mtr.state == MTR_COMMITTED); if (error == DB_SUCCESS) { @@ -2263,8 +2201,6 @@ row_log_table_apply_op( ulint extra_size; const mrec_t* next_mrec; dtuple_t* old_pk; - row_ext_t* ext; - ulint ext_size; ut_ad(dict_index_is_clust(dup->index)); ut_ad(dup->index->table != log->table); @@ -2272,7 +2208,7 @@ row_log_table_apply_op( *error = DB_SUCCESS; - /* 3 = 1 (op type) + 1 (ext_size) + at least 1 byte payload */ + /* 3 = 1 (op type) + 1 (extra_size) + at least 1 byte payload */ if (mrec + 3 >= mrec_end) { return(NULL); } @@ -2322,14 +2258,12 @@ row_log_table_apply_op( break; case ROW_T_DELETE: - /* 1 (extra_size) + 4 (ext_size) + at least 1 (payload) */ - if (mrec + 6 >= mrec_end) { + /* 1 (extra_size) + at least 1 (payload) */ + if (mrec + 2 >= mrec_end) { return(NULL); } extra_size = *mrec++; - ext_size = mach_read_from_4(mrec); - mrec += 4; ut_ad(mrec < mrec_end); /* We assume extra_size < 0x100 for the PRIMARY KEY prefix. @@ -2338,40 +2272,16 @@ row_log_table_apply_op( rec_offs_set_n_fields(offsets, new_index->n_uniq + 2); rec_init_offsets_temp(mrec, new_index, offsets); - next_mrec = mrec + rec_offs_data_size(offsets) + ext_size; + next_mrec = mrec + rec_offs_data_size(offsets); if (next_mrec > mrec_end) { return(NULL); } log->head.total += next_mrec - mrec_start; - /* If there are external fields, retrieve those logged - prefix info and reconstruct the row_ext_t */ - if (ext_size) { - /* We use memcpy to avoid unaligned - access on some non-x86 platforms.*/ - ext = static_cast( - mem_heap_dup(heap, - mrec + rec_offs_data_size(offsets), - ext_size)); - - byte* ext_start = reinterpret_cast(ext); - - ulint ext_len = sizeof(*ext) - + (ext->n_ext - 1) * sizeof ext->len; - - ext->ext = reinterpret_cast(ext_start + ext_len); - ext_len += ext->n_ext * sizeof(*ext->ext); - - ext->buf = static_cast(ext_start + ext_len); - } else { - ext = NULL; - } - *error = row_log_table_apply_delete( - thr, new_trx_id_col, - mrec, offsets, offsets_heap, heap, - log, ext); + new_trx_id_col, + mrec, offsets, offsets_heap, heap, log); break; case ROW_T_UPDATE: diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index d9585818577cac641ceaa7c01a34dc376adccc91..9f8fc39e06b92d1bc3c584166d19d0938c00d4f6 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -3111,7 +3111,8 @@ row_merge_drop_indexes( A concurrent purge will be prevented by dict_operation_lock. */ - if (!locked && table->n_ref_count > 1) { + if (!locked && (table->n_ref_count > 1 + || UT_LIST_GET_FIRST(table->locks))) { /* We will have to drop the indexes later, when the table is guaranteed to be no longer in use. Mark the indexes as incomplete and corrupted, so that other diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 549a19799b33ec9501145b8119bedc2ab4ebf614..2b6f38ba2af70db7b41f81cbba34bc05151af653 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2015, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1504,8 +1504,7 @@ row_insert_for_mysql( doc_ids difference should not exceed FTS_DOC_ID_MAX_STEP value. */ - if (next_doc_id > 1 - && doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { + if (doc_id - next_doc_id >= FTS_DOC_ID_MAX_STEP) { fprintf(stderr, "InnoDB: Doc ID " UINT64PF " is too" " big. Its difference with largest" @@ -3541,6 +3540,8 @@ row_truncate_table_for_mysql( fil_space_release(space); } + buf_LRU_drop_page_hash_for_tablespace(table); + if (flags != ULINT_UNDEFINED && fil_discard_tablespace(space_id) == DB_SUCCESS) { @@ -4240,6 +4241,21 @@ row_drop_table_for_mysql( rw_lock_x_unlock(dict_index_get_lock(index)); } + if (table->space != TRX_SYS_SPACE) { + /* On DISCARD TABLESPACE, we would not drop the + adaptive hash index entries. If the tablespace is + missing here, delete-marking the record in SYS_INDEXES + would not free any pages in the buffer pool. Thus, + dict_index_remove_from_cache() would hang due to + adaptive hash index entries existing in the buffer + pool. To prevent this hang, and also to guarantee + that btr_search_drop_page_hash_when_freed() will avoid + calling btr_search_drop_page_hash_index() while we + hold the InnoDB dictionary lock, we will drop any + adaptive hash index entries upfront. */ + buf_LRU_drop_page_hash_for_tablespace(table); + } + /* We use the private SQL parser of Innobase to generate the query graphs needed in deleting the dictionary data from system tables in Innobase. Deleting a row from SYS_INDEXES table also @@ -5270,7 +5286,8 @@ row_rename_table_for_mysql( } } - if (dict_table_has_fts_index(table) + if ((dict_table_has_fts_index(table) + || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) && !dict_tables_have_same_db(old_name, new_name)) { err = fts_rename_aux_tables(table, new_name, trx); if (err != DB_TABLE_NOT_FOUND) { @@ -5372,6 +5389,7 @@ row_rename_table_for_mysql( trx_rollback_to_savepoint(trx, NULL); trx->error_state = DB_SUCCESS; } + table->data_dir_path= NULL; } funct_exit: diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc index 03ae6822fb7a16dd801518ae28897f0e1fec07ab..b6b5d107885da1a9aa1df410b755010a171a3569 100644 --- a/storage/xtradb/row/row0sel.cc +++ b/storage/xtradb/row/row0sel.cc @@ -3685,6 +3685,117 @@ row_search_idx_cond_check( return(result); } +/** Return the record field length in characters. +@param[in] col table column of the field +@param[in] field_no field number +@param[in] rec physical record +@param[in] offsets field offsets in the physical record +@return field length in characters. */ +static +size_t +rec_field_len_in_chars( + const dict_col_t* col, + const ulint field_no, + const rec_t* rec, + const ulint* offsets) +{ + const ulint cset = dtype_get_charset_coll(col->prtype); + const CHARSET_INFO* cs = all_charsets[cset]; + ulint rec_field_len; + const char* rec_field = reinterpret_cast( + rec_get_nth_field( + rec, offsets, field_no, &rec_field_len)); + + if (UNIV_UNLIKELY(!cs)) { + ib_logf(IB_LOG_LEVEL_WARN, "Missing collation " ULINTPF, cset); + return SIZE_T_MAX; + } + + return(cs->cset->numchars(cs, rec_field, rec_field + rec_field_len)); +} + + +/** Avoid the clustered index lookup if all the following conditions +are true: +1) all columns are in secondary index +2) all values for columns that are prefix-only indexes are shorter +than the prefix size. This optimization can avoid many IOs for certain schemas. +@return true, to avoid clustered index lookup. */ +static +bool row_search_with_covering_prefix( + row_prebuilt_t* prebuilt, + const rec_t* rec, + const ulint* offsets) +{ + const dict_index_t* index = prebuilt->index; + ut_ad(!dict_index_is_clust(index)); + + if (!srv_prefix_index_cluster_optimization) { + return false; + } + + /** Optimization only applicable if the number of secondary index + fields are greater than or equal to number of clustered index fields. */ + if (prebuilt->n_template > index->n_fields) { + return false; + } + + for (ulint i = 0; i < prebuilt->n_template; i++) { + mysql_row_templ_t* templ = prebuilt->mysql_template + i; + ulint j = templ->rec_prefix_field_no; + + /** Condition (1) : is the field in the index. */ + if (j == ULINT_UNDEFINED) { + return false; + } + + /** Condition (2): If this is a prefix index then + row's value size shorter than prefix length. */ + + if (!templ->rec_field_is_prefix) { + continue; + } + + ulint rec_size = rec_offs_nth_size(offsets, j); + const dict_field_t* field = dict_index_get_nth_field(index, j); + ulint max_chars = field->prefix_len / templ->mbmaxlen; + + ut_a(field->prefix_len > 0); + + if (rec_size < max_chars) { + /* Record in bytes shorter than the index + prefix length in char. */ + continue; + } + + if (rec_size * templ->mbminlen >= field->prefix_len) { + /* Shortest representation string by the + byte length of the record is longer than the + maximum possible index prefix. */ + return false; + } + + + size_t num_chars = rec_field_len_in_chars( + field->col, j, rec, offsets); + + if (num_chars >= max_chars) { + /* No of chars to store the record exceeds + the index prefix character length. */ + return false; + } + } + + for (ulint i = 0; i < prebuilt->n_template; i++) { + mysql_row_templ_t* templ = prebuilt->mysql_template + i; + templ->rec_field_no = templ->rec_prefix_field_no; + ut_a(templ->rec_field_no != ULINT_UNDEFINED); + } + + srv_stats.n_sec_rec_cluster_reads_avoided.inc(); + return true; +} + /********************************************************************//** Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next @@ -3748,7 +3859,6 @@ row_search_for_mysql( ulint* offsets = offsets_; ibool table_lock_waited = FALSE; byte* next_buf = 0; - bool use_clustered_index = false; rec_offs_init(offsets_); @@ -4555,9 +4665,27 @@ row_search_for_mysql( ulint lock_type; + if (srv_locks_unsafe_for_binlog + || trx->isolation_level <= TRX_ISO_READ_COMMITTED) { + /* At READ COMMITTED or READ UNCOMMITTED + isolation levels, do not lock committed + delete-marked records. */ + if (!rec_get_deleted_flag(rec, comp)) { + goto no_gap_lock; + } + if (trx_id_t trx_id = index == clust_index + ? row_get_rec_trx_id(rec, index, offsets) + : row_vers_impl_x_locked(rec, index, offsets)) { + if (trx_rw_is_active(trx_id, NULL)) { + /* The record belongs to an active + transaction. We must acquire a lock. */ + goto no_gap_lock; + } + } + goto locks_ok_del_marked; + } + if (!set_also_gap_locks - || srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED || (unique_search && !rec_get_deleted_flag(rec, comp))) { goto no_gap_lock; @@ -4627,7 +4755,11 @@ row_search_for_mysql( a deadlock and the transaction had to wait then release the lock it is waiting on. */ + lock_mutex_enter(); + trx_mutex_enter(trx); err = lock_trx_handle_wait(trx); + lock_mutex_exit(); + trx_mutex_exit(trx); switch (err) { case DB_SUCCESS: @@ -4748,20 +4880,9 @@ row_search_for_mysql( page_rec_is_comp() cannot be used! */ if (rec_get_deleted_flag(rec, comp)) { - +locks_ok_del_marked: /* The record is delete-marked: we can skip it */ - if ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE - && !did_semi_consistent_read) { - - /* No need to keep a lock on a delete-marked record - if we do not want to use next-key locking. */ - - row_unlock_for_mysql(prebuilt, TRUE); - } - /* This is an optimization to skip setting the next key lock on the record that follows this delete-marked record. This optimization works because of the unique search criteria @@ -4806,71 +4927,10 @@ row_search_for_mysql( break; } - /* Get the clustered index record if needed, if we did not do the - search using the clustered index... */ - - use_clustered_index = - (index != clust_index && prebuilt->need_to_access_clustered); - - if (use_clustered_index && srv_prefix_index_cluster_optimization - && prebuilt->n_template <= index->n_fields) { - /* ...but, perhaps avoid the clustered index lookup if - all of the following are true: - 1) all columns are in the secondary index - 2) all values for columns that are prefix-only - indexes are shorter than the prefix size - This optimization can avoid many IOs for certain schemas. - */ - bool row_contains_all_values = true; - unsigned int i; - for (i = 0; i < prebuilt->n_template; i++) { - /* Condition (1) from above: is the field in the - index (prefix or not)? */ - const mysql_row_templ_t* templ = - prebuilt->mysql_template + i; - ulint secondary_index_field_no = - templ->rec_prefix_field_no; - if (secondary_index_field_no == ULINT_UNDEFINED) { - row_contains_all_values = false; - break; - } - /* Condition (2) from above: if this is a - prefix, is this row's value size shorter - than the prefix? */ - if (templ->rec_field_is_prefix) { - ulint record_size = rec_offs_nth_size( - offsets, - secondary_index_field_no); - const dict_field_t *field = - dict_index_get_nth_field( - index, - secondary_index_field_no); - ut_a(field->prefix_len > 0); - if (record_size >= field->prefix_len - / templ->mbmaxlen) { - row_contains_all_values = false; - break; - } - } - } - /* If (1) and (2) were true for all columns above, use - rec_prefix_field_no instead of rec_field_no, and skip - the clustered lookup below. */ - if (row_contains_all_values) { - for (i = 0; i < prebuilt->n_template; i++) { - mysql_row_templ_t* templ = - prebuilt->mysql_template + i; - templ->rec_field_no = - templ->rec_prefix_field_no; - ut_a(templ->rec_field_no != ULINT_UNDEFINED); - } - use_clustered_index = false; - srv_stats.n_sec_rec_cluster_reads_avoided.inc(); + if (index != clust_index && prebuilt->need_to_access_clustered) { + if (row_search_with_covering_prefix(prebuilt, rec, offsets)) { + goto use_covering_index; } - } - - if (use_clustered_index) { - requires_clust_rec: ut_ad(index != clust_index); /* We use a 'goto' to the preceding label if a consistent @@ -4956,6 +5016,7 @@ row_search_for_mysql( } } } else { +use_covering_index: result_rec = rec; } diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 9ac72f8d0685074f4a50d45a0b0e32a1eda9684e..93ccc07c9af19b5bb6c2ddbdeb29e85f5bfc3ed5 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1806,6 +1806,23 @@ row_upd_store_row( } } +#ifdef WITH_WSREP +/** Determine if a FOREIGN KEY constraint needs to be processed. +@param[in] node query node +@param[in] trx transaction +@return whether the node cannot be ignored */ + +inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) +{ + if (!wsrep_on_trx(trx)) { + return false; + } + return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE + || static_cast(node->common.parent)->cascade_node + != node; +} +#endif /* WITH_WSREP */ + /***********************************************************//** Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error @@ -1836,7 +1853,7 @@ row_upd_sec_index_entry( referenced = row_upd_index_is_referenced(index, trx); #ifdef WITH_WSREP - ibool foreign = wsrep_row_upd_index_is_foreign(index, trx); + bool foreign = wsrep_row_upd_index_is_foreign(index, trx); #endif /* WITH_WSREP */ heap = mem_heap_create(1024); @@ -1968,61 +1985,61 @@ row_upd_sec_index_entry( row_ins_sec_index_entry() below */ if (!rec_get_deleted_flag( rec, dict_table_is_comp(index->table))) { -#ifdef WITH_WSREP - que_node_t *parent = que_node_get_parent(node); -#endif /* WITH_WSREP */ err = btr_cur_del_mark_set_sec_rec( 0, btr_cur, TRUE, thr, &mtr); - if (err == DB_SUCCESS && referenced) { - - ulint* offsets; - - offsets = rec_get_offsets( - rec, index, NULL, ULINT_UNDEFINED, - &heap); - - /* NOTE that the following call loses - the position of pcur ! */ - err = row_upd_check_references_constraints( - node, &pcur, index->table, - index, offsets, thr, &mtr); + if (err != DB_SUCCESS) { + break; } + #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && - wsrep_on_trx(trx) && - !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - !(parent && que_node_get_type(parent) == - QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { - ulint* offsets = - rec_get_offsets( + if (!referenced && foreign + && wsrep_must_process_fk(node, trx) + && !wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { + ulint* offsets = rec_get_offsets( rec, index, NULL, ULINT_UNDEFINED, &heap); + err = wsrep_row_upd_check_foreign_constraints( node, &pcur, index->table, index, offsets, thr, &mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: sec index FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } } #endif /* WITH_WSREP */ } - break; + + if (referenced) { + + ulint* offsets; + + offsets = rec_get_offsets( + rec, index, NULL, ULINT_UNDEFINED, + &heap); + + /* NOTE that the following call loses + the position of pcur ! */ + err = row_upd_check_references_constraints( + node, &pcur, index->table, + index, offsets, thr, &mtr); + } } btr_pcur_close(&pcur); @@ -2191,9 +2208,6 @@ row_upd_clust_rec_by_insert( rec_t* rec; ulint* offsets = NULL; -#ifdef WITH_WSREP - que_node_t *parent = que_node_get_parent(node); -#endif /* WITH_WSREP */ ut_ad(node); ut_ad(dict_index_is_clust(index)); @@ -2278,35 +2292,31 @@ row_upd_clust_rec_by_insert( if (err != DB_SUCCESS) { goto err_exit; } - } #ifdef WITH_WSREP - if (!referenced && wsrep_on_trx(trx) && - !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { + } else if ((foreign && wsrep_must_process_fk(node, trx))) { err = wsrep_row_upd_check_foreign_constraints( node, pcur, table, index, offsets, thr, mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: insert FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } - if (err != DB_SUCCESS) { - goto err_exit; - } - } #endif /* WITH_WSREP */ + } } mtr_commit(mtr); @@ -2512,7 +2522,7 @@ row_upd_del_mark_clust_rec( dberr_t err; #ifdef WITH_WSREP rec_t* rec; - que_node_t *parent = que_node_get_parent(node); + trx_t* trx = thr_get_trx(thr) ; #endif /* WITH_WSREP */ ut_ad(node); @@ -2541,38 +2551,37 @@ row_upd_del_mark_clust_rec( btr_cur_get_block(btr_cur), btr_cur_get_rec(btr_cur), #endif /* WITH_WSREP */ index, offsets, thr, mtr); - if (err == DB_SUCCESS && referenced) { + if (err != DB_SUCCESS) { + } else if (referenced) { /* NOTE that the following call loses the position of pcur ! */ err = row_upd_check_references_constraints( node, pcur, index->table, index, offsets, thr, mtr); - } #ifdef WITH_WSREP - trx_t* trx = thr_get_trx(thr) ; - if (err == DB_SUCCESS && !referenced && wsrep_on_trx(trx) && - !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && - ((upd_node_t*)parent)->cascade_node == node) && - foreign - ) { + } else if (foreign && wsrep_must_process_fk(node, trx)) { err = wsrep_row_upd_check_foreign_constraints( node, pcur, index->table, index, offsets, thr, mtr); + switch (err) { case DB_SUCCESS: case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) fprintf (stderr, - "WSREP: clust rec FK check fail for deadlock"); + if (wsrep_debug) { + ib_logf(IB_LOG_LEVEL_WARN, + "WSREP: sec index FK check fail for deadlock: " + " index %s table %s", index->name, index->table->name); + } break; default: - fprintf (stderr, - "WSREP: clust rec referenced FK check fail: %d", - (int)err); + ib_logf(IB_LOG_LEVEL_ERROR, + "WSREP: referenced FK check fail: %s index %s table %s", + ut_strerr(err), index->name, index->table->name); break; } - } #endif /* WITH_WSREP */ + } mtr_commit(mtr); diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index 02314db6b07dabaf164869006bea4c89af2d5f38..31e8709593443d6a470f03dc50da1d0084b6add7 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -86,6 +86,12 @@ ibool innobase_get_slow_log(); in the server */ UNIV_INTERN ulint srv_activity_count = 0; +#include + +#ifdef WITH_WSREP +extern int wsrep_debug; +extern int wsrep_trx_is_aborting(void *thd_ptr); +#endif /* The following is the maximum allowed duration of a lock wait. */ UNIV_INTERN ulong srv_fatal_semaphore_wait_threshold = DEFAULT_SRV_FATAL_SEMAPHORE_TIMEOUT; @@ -565,16 +571,6 @@ static ulint srv_n_system_rows_read_old = 0; UNIV_INTERN ulint srv_truncated_status_writes = 0; UNIV_INTERN ulint srv_available_undo_logs = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_saved = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect512 = 0; -UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect4096 = 0; -UNIV_INTERN ib_uint64_t srv_index_pages_written = 0; -UNIV_INTERN ib_uint64_t srv_non_index_pages_written = 0; -UNIV_INTERN ib_uint64_t srv_pages_page_compressed = 0; -UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op = 0; -UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op_saved = 0; -UNIV_INTERN ib_uint64_t srv_index_page_decompressed = 0; - /* Ensure status variables are on separate cache lines */ #ifdef __powerpc__ @@ -3240,6 +3236,9 @@ srv_purge_should_exit(ulint n_purged) } /* Slow shutdown was requested. */ if (n_purged) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "InnoDB " ULINTPF " pages purged", n_purged); /* The previous round still did some work. */ return(false); } @@ -3444,7 +3443,6 @@ srv_do_purge( (++count % TRX_SYS_N_RSEGS) == 0); *n_total_purged += n_pages_purged; - } while (!srv_purge_should_exit(n_pages_purged) && n_pages_purged > 0 && purge_sys->state == PURGE_STATE_RUN); diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 2aa2426ca9c71492830c2c3e46ef8223a6048a1f..4ed310089acc6381f85b452d033be2c9fdb45dd7 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -1505,14 +1505,12 @@ srv_undo_tablespaces_init( if (backup_mode) { ut_ad(!create_new_db); - /* MDEV-13561 FIXME: Determine srv_undo_space_id_start - from the undo001 file. */ - srv_undo_space_id_start = 1; - for (i = 0; i < n_undo_tablespaces; i++) { undo_tablespace_ids[i] = i + srv_undo_space_id_start; } + + prev_space_id = srv_undo_space_id_start - 1; } } diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc index 1075064a2d6e4c00b342cbd0092fbcb29f20a37e..56b7120fa34bc9f85d1a7c8f2ce75361d7e6c3f5 100644 --- a/storage/xtradb/trx/trx0roll.cc +++ b/storage/xtradb/trx/trx0roll.cc @@ -25,7 +25,7 @@ Created 3/26/1996 Heikki Tuuri *******************************************************/ #include "my_config.h" -#include +#include #include "trx0roll.h" @@ -764,11 +764,17 @@ trx_roll_must_shutdown() n_rows += t->undo_no; } } + + if (n_rows > 0) { + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, + "To roll back: " ULINTPF " transactions, " + "%llu rows", n_trx, n_rows); + } + ib_logf(IB_LOG_LEVEL_INFO, "To roll back: " ULINTPF " transactions, " "%llu rows", n_trx, n_rows); - sd_notifyf(0, "STATUS=To roll back: " ULINTPF " transactions, " - "%llu rows", n_trx, n_rows); } mutex_exit(&recv_sys->mutex); diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 2b0b05dc3272c32a7cc229a3b2fe034b596e9c35..b3d709ccf8a767062bdcc6856ccb5f91fad1462e 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2017, MariaDB Corporation. +Copyright (c) 2015, 2018, 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 @@ -1472,6 +1472,8 @@ trx_commit_in_memory( if (lsn) { ulint flush_log_at_trx_commit; + DEBUG_SYNC_C("after_trx_committed_in_memory"); + if (trx->insert_undo != NULL) { trx_undo_insert_cleanup(trx); diff --git a/storage/xtradb/trx/trx0undo.cc b/storage/xtradb/trx/trx0undo.cc index 0d5a0f55f0dcd6b1742fb7538febaa64d80528a3..594416ba34d6917fec6111ccce0fe990d98f0930 100644 --- a/storage/xtradb/trx/trx0undo.cc +++ b/storage/xtradb/trx/trx0undo.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -1989,7 +1989,9 @@ trx_undo_insert_cleanup( mutex_exit(&(rseg->mutex)); - trx_undo_seg_free(undo); + if (!srv_read_only_mode) { + trx_undo_seg_free(undo); + } mutex_enter(&(rseg->mutex)); diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc index fd52537ae11933b2b99fc0d4d796747d8367b0bf..695be4907e01ba0b28571fc5788a699c6ba00d20 100644 --- a/storage/xtradb/ut/ut0ut.cc +++ b/storage/xtradb/ut/ut0ut.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -47,6 +47,10 @@ Created 5/11/1994 Heikki Tuuri #endif /* UNIV_HOTBACKUP */ #ifdef __WIN__ +#include /* For sql_print_error */ +typedef VOID(WINAPI *time_fn)(LPFILETIME); +static time_fn ut_get_system_time_as_file_time = GetSystemTimeAsFileTime; + /*****************************************************************//** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix epoch starts from 1970/1/1. For selection of constant see: @@ -54,6 +58,28 @@ epoch starts from 1970/1/1. For selection of constant see: #define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL) +/** +Initialise highest available time resolution API on Windows +@return 0 if all OK else -1 */ +int +ut_win_init_time() +{ + HMODULE h = LoadLibrary("kernel32.dll"); + if (h != NULL) + { + time_fn pfn = (time_fn)GetProcAddress(h, "GetSystemTimePreciseAsFileTime"); + if (pfn != NULL) + { + ut_get_system_time_as_file_time = pfn; + } + return false; + } + DWORD error = GetLastError(); + sql_print_error( + "LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu", error); + return(-1); +} + /*****************************************************************//** This is the Windows version of gettimeofday(2). @return 0 if all OK else -1 */ @@ -72,7 +98,7 @@ ut_gettimeofday( return(-1); } - GetSystemTimeAsFileTime(&ft); + ut_get_system_time_as_file_time(&ft); tm = (ib_int64_t) ft.dwHighDateTime << 32; tm |= ft.dwLowDateTime; diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 3b6e86030ab4ecc590229806a357921299c04b4c..dff4610d4906caf530328d8f966191114c5245ed 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -41,13 +41,20 @@ ELSE() SET(inst_location ${INSTALL_SUPPORTFILESDIR}) ENDIF() -FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small wsrep) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh +FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} DESTINATION ${inst_location} COMPONENT IniFiles) ENDFOREACH() +IF(WITH_WSREP) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep.cnf.sh + ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} + DESTINATION ${inst_location} COMPONENT IniFiles) +ENDIF() + IF(UNIX) SET(prefix ${CMAKE_INSTALL_PREFIX}) FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index c9ea270a78154ff9f73876241c99413a76e8d831..a60ec248cecfc2e800a2fe33b08502fdf0a7d7fd 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -25,7 +25,6 @@ # Description: MariaDB is a very fast and reliable SQL database engine. ### END INIT INFO -# If you install MariaDB on some other places than @prefix@, then you # have to do one of the following things for this script to work: # # - Run this script from within the MariaDB installation directory diff --git a/support-files/policy/selinux/mariadb-server.fc b/support-files/policy/selinux/mariadb-server.fc index 1a69ecc2c40064e9ce3e5ee3eb3fa59e03f490b5..409f72923aae1f06aefa4c3bcc410da37d0873d6 100644 --- a/support-files/policy/selinux/mariadb-server.fc +++ b/support-files/policy/selinux/mariadb-server.fc @@ -1,4 +1,4 @@ -# This SELinux file contexts (.fc) file has been copied under BSD License from +# This SELinux file contexts (.fc) file has been copied under New BSD License from # Percona XtraDB Cluster. /etc/init\.d/rc\.d/mysql -- gen_context(system_u:object_r:mysqld_initrc_exec_t,s0) diff --git a/support-files/policy/selinux/mariadb-server.te b/support-files/policy/selinux/mariadb-server.te index 34d79326b10d7a8e8e2739c64eb581f44ff0ebc2..45ef40f41534c481c1461f93e4d9213099f2c3c8 100644 --- a/support-files/policy/selinux/mariadb-server.te +++ b/support-files/policy/selinux/mariadb-server.te @@ -1,4 +1,4 @@ -# This SELinux type enforcement (.te) file has been copied under BSD License +# This SELinux type enforcement (.te) file has been copied under New BSD License # from Percona XtraDB Cluster, along with some additions. module mariadb-server 1.0; diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh index a5390855ca17a54222c884636952d23f88b6b472..51ce3dca2ddad469169174cfc7d6175d85b15574 100644 --- a/support-files/wsrep.cnf.sh +++ b/support-files/wsrep.cnf.sh @@ -30,6 +30,9 @@ bind-address=0.0.0.0 ## WSREP options ## +# Enable wsrep +wsrep_on=1 + # Full path to wsrep provider library or 'none' wsrep_provider=none diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index b7211989f1f858bfe5711ba3b26beb419d7cd989..71fb3894b3c202ea05dc84ef3b6a977b28f8a686 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -1409,8 +1409,7 @@ int main(int argc, char **argv) for (i= 0; i < argc; i++) original_argv[i]= strdup(argv[i]); - if (load_defaults("my", client_test_load_default_groups, &argc, &argv)) - exit(1); + load_defaults_or_exit("my", client_test_load_default_groups, &argc, &argv); get_options(&argc, &argv); /* Set main opt_count. */ diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index c367e7ca35dda124c024c27c773c60249ea4ced0..b63bcbaa03755b97ab96d5200c0d495bc911dc41 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -7095,11 +7095,7 @@ static void test_embedded_start_stop() MY_INIT(argv[0]); /* Load the client defaults from the .cnf file[s]. */ - if (load_defaults("my", client_test_load_default_groups, &argc, &argv)) - { - myerror("load_defaults failed"); - exit(1); - } + load_defaults_or_exit("my", client_test_load_default_groups, &argc, &argv); /* Parse the options (including the ones given from defaults files). */ get_options(&argc, &argv); @@ -7147,12 +7143,7 @@ static void test_embedded_start_stop() MY_INIT(argv[0]); - if (load_defaults("my", client_test_load_default_groups, &argc, &argv)) - { - myerror("load_defaults failed \n "); - exit(1); - } - + load_defaults_or_exit("my", client_test_load_default_groups, &argc, &argv); get_options(&argc, &argv); /* Must start the main embedded server again after the test. */ diff --git a/tests/thread_test.c b/tests/thread_test.c index bf0fb8ea2c0181d529ad624ebd0fb0b5a04757b2..38e453e9cb8434eba093c6797fd2d481f355a504 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -168,8 +168,8 @@ static void get_options(int argc, char **argv) { int ho_error; - if ((ho_error= load_defaults("my",load_default_groups,&argc,&argv)) || - (ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) + load_defaults_or_exit("my", load_default_groups, &argc, &argv); + if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); free_defaults(argv); diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc index 31f98562521b86e71428debe2ef38a25dca89395..1b04f8eb0d3a3b9c313b1d83bf3968377f039cac 100644 --- a/unittest/sql/mf_iocache-t.cc +++ b/unittest/sql/mf_iocache-t.cc @@ -187,10 +187,76 @@ void mdev9044() close_cached_file(&info); } +/* 2 Reads (with my_b_fill) in cache makes second read to fail */ +void mdev10259() +{ + int res; + uchar buf[200]; + memset(buf, FILL, sizeof(buf)); + + diag("MDEV-10259- mysqld crash with certain statement length and order with" + " Galera and encrypt-tmp-files=1"); + + init_io_cache_encryption(); + + res= open_cached_file(&info, 0, 0, CACHE_SIZE, 0); + ok(res == 0, "open_cached_file" INFO_TAIL); + + res= my_b_write(&info, buf, sizeof(buf)); + ok(res == 0 && info.pos_in_file == 0, "200 write" INFO_TAIL); + + res= my_b_flush_io_cache(&info, 1); + ok(res == 0, "flush" INFO_TAIL); + + ulong saved_pos= my_b_tell(&info); + res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0); + ok(res == 0, "reinit READ_CACHE" INFO_TAIL); + + res= my_b_fill(&info); + ok(res == 200, "fill" INFO_TAIL); + + res= my_b_fill(&info); + ok(res == 0, "fill" INFO_TAIL); + + res= my_b_fill(&info); + ok(res == 0, "fill" INFO_TAIL); + + res= reinit_io_cache(&info, WRITE_CACHE, saved_pos, 0, 0); + ok(res == 0, "reinit WRITE_CACHE" INFO_TAIL); + + res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0); + ok(res == 0, "reinit READ_CACHE" INFO_TAIL); + + ok(200 == my_b_bytes_in_cache(&info),"my_b_bytes_in_cache == 200"); + + res= my_b_fill(&info); + ok(res == 0, "fill" INFO_TAIL); + + res= my_b_fill(&info); + ok(res == 0, "fill" INFO_TAIL); + + res= my_b_fill(&info); + ok(res == 0, "fill" INFO_TAIL); + + res= reinit_io_cache(&info, WRITE_CACHE, saved_pos, 0, 0); + ok(res == 0, "reinit WRITE_CACHE" INFO_TAIL); + + res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0); + ok(res == 0, "reinit READ_CACHE" INFO_TAIL); + + ok(200 == my_b_bytes_in_cache(&info),"my_b_bytes_in_cache == 200"); + + res= my_b_read(&info, buf, sizeof(buf)) || data_bad(buf, sizeof(buf)); + ok(res == 0 && info.pos_in_file == 0, "large read" INFO_TAIL); + + close_cached_file(&info); + +} + int main(int argc __attribute__((unused)),char *argv[]) { MY_INIT(argv[0]); - plan(29); + plan(46); /* temp files with and without encryption */ encrypt_tmp_files= 1; @@ -202,6 +268,10 @@ int main(int argc __attribute__((unused)),char *argv[]) /* regression tests */ mdev9044(); + encrypt_tmp_files= 1; + mdev10259(); + encrypt_tmp_files= 0; + my_end(0); return exit_status(); }