revision-id: c5a8583b3146613429d88c1c044de88a4c4c94b0 (mariadb-galera-10.0.35-14-gc5a8583b314) parent(s): c863159c320008676aff978a7cdde5732678f975 e023f9a4d5a620b54d7f7132567150d80b630692 author: Jan Lindström committer: Jan Lindström timestamp: 2018-08-02 11:44:02 +0300 message: Merge tag 'mariadb-10.0.36' into 10.0-galera .gitignore | 6 + CMakeLists.txt | 6 + client/mysqldump.c | 15 +- client/mysqlslap.c | 4 +- client/mysqltest.cc | 1 + cmake/install_macros.cmake | 8 + cmake/mysql_add_executable.cmake | 3 + cmake/os/Windows.cmake | 2 +- include/m_ctype.h | 28 +- include/sql_common.h | 2 +- .../rpl_tests/rpl_implicit_commit_binlog.test | 708 +++------------------ mysql-test/include/ctype_mdev13118.inc | 15 + mysql-test/lib/My/SafeProcess/safe_process.cc | 14 +- mysql-test/mysql-test-run.pl | 83 +-- mysql-test/r/alter_table.result | 84 +++ mysql-test/r/assign_key_cache.result | 13 + ...e-5405.result => assign_key_cache_debug.result} | 0 mysql-test/r/auto_increment.result | 29 + mysql-test/r/create_or_replace.result | 20 + mysql-test/r/ctype_binary.result | 23 + mysql-test/r/ctype_eucjpms.result | 23 + mysql-test/r/ctype_euckr.result | 29 + mysql-test/r/ctype_gbk.result | 23 + mysql-test/r/ctype_latin1.result | 23 + mysql-test/r/ctype_ucs.result | 23 + mysql-test/r/ctype_ujis.result | 23 + mysql-test/r/ctype_utf16.result | 23 + mysql-test/r/ctype_utf16le.result | 29 + mysql-test/r/ctype_utf32.result | 23 + mysql-test/r/ctype_utf8.result | 23 + mysql-test/r/ctype_utf8mb4.result | 23 + mysql-test/r/derived.result | 33 + mysql-test/r/grant.result | 9 +- mysql-test/r/grant2.result | 3 +- mysql-test/r/grant_not_windows.result | 7 + mysql-test/r/having.result | 17 + mysql-test/r/implicit_commit.result | 4 +- mysql-test/r/information_schema.result | 2 +- mysql-test/r/insert_select.result | 9 + mysql-test/r/join.result | 40 ++ mysql-test/r/join_cache.result | 33 + mysql-test/r/join_outer.result | 50 ++ mysql-test/r/join_outer_jcl6.result | 50 ++ mysql-test/r/limit.result | 16 + mysql-test/r/lock.result | 2 +- mysql-test/r/myisam.result | 8 + mysql-test/r/mysqldump.result | 15 + mysql-test/r/mysqlslap.result | 3 + mysql-test/r/rename.result | 70 ++ mysql-test/r/selectivity.result | 70 +- mysql-test/r/selectivity_innodb.result | 70 +- mysql-test/r/stat_tables.result | 60 ++ mysql-test/r/stat_tables_innodb.result | 60 ++ mysql-test/r/statistics.result | 20 + mysql-test/r/statistics_close.result | 6 + mysql-test/r/subselect.result | 16 + mysql-test/r/subselect4.result | 6 +- mysql-test/r/subselect_mat.result | 93 +++ mysql-test/r/subselect_mat_cost_bugs.result | 4 +- mysql-test/r/subselect_no_exists_to_in.result | 16 + mysql-test/r/subselect_no_mat.result | 16 + mysql-test/r/subselect_no_opts.result | 16 + mysql-test/r/subselect_no_scache.result | 16 + mysql-test/r/subselect_no_semijoin.result | 16 + mysql-test/r/subselect_sj2_mat.result | 198 ++++++ mysql-test/r/subselect_sj_mat.result | 93 +++ mysql-test/r/subselect_sj_nonmerged.result | 6 +- mysql-test/r/union.result | 16 + mysql-test/std_data/frm/t1.frm | Bin 0 -> 8584 bytes .../suite/binlog/include/check_binlog_size.inc | 31 + .../suite/binlog/r/binlog_tmp_table_row.result | 7 + .../suite/binlog/t/binlog_tmp_table_row.test | 30 + mysql-test/suite/federated/have_federatedx.inc | 2 +- .../suite/funcs_1/r/is_engines_archive.result | 2 +- mysql-test/suite/funcs_1/r/is_engines_csv.result | 2 +- .../suite/funcs_1/r/is_engines_federated.result | 2 +- .../suite/funcs_1/r/is_engines_myisam.result | 2 +- mysql-test/suite/handler/handler.inc | 2 + mysql-test/suite/handler/interface.result | 2 +- mysql-test/suite/handler/interface.test | 2 +- mysql-test/suite/handler/ps.result | 9 + mysql-test/suite/handler/ps.test | 11 + mysql-test/suite/heap/heap_auto_increment.result | 29 + mysql-test/suite/heap/heap_auto_increment.test | 25 + .../suite/innodb/r/alter_partitioned_xa.result | 15 + mysql-test/suite/innodb/r/innodb-alter.result | 29 + mysql-test/suite/innodb/r/innodb-wl5522.result | 263 +++++++- mysql-test/suite/innodb/r/innodb_bug54044.result | 6 - mysql-test/suite/innodb/r/rename_table.result | 5 + .../suite/innodb/t/alter_partitioned_xa.test | 31 + mysql-test/suite/innodb/t/innodb-alter.test | 21 + mysql-test/suite/innodb/t/innodb-mdev7046.test | 7 +- mysql-test/suite/innodb/t/innodb-wl5522.test | 258 +++++++- mysql-test/suite/innodb/t/innodb_bug54044.test | 10 - mysql-test/suite/innodb/t/rename_table.test | 11 + .../r/{innodb-fts-basic.result => basic.result} | 34 + mysql-test/suite/innodb_fts/r/sync_ddl.result | 117 ++++ .../t/{innodb-fts-basic.test => basic.test} | 39 +- mysql-test/suite/innodb_fts/t/sync_ddl.test | 177 ++++++ mysql-test/suite/maria/alter.result | 16 + mysql-test/suite/maria/alter.test | 17 + mysql-test/suite/maria/lock.result | 10 + mysql-test/suite/maria/lock.test | 12 + mysql-test/suite/maria/maria.result | 37 ++ mysql-test/suite/maria/maria.test | 37 ++ .../parts/r/alter_data_directory_innodb.result | 65 ++ mysql-test/suite/parts/r/truncate_locked.result | 7 + .../suite/parts/t/alter_data_directory_innodb.test | 46 ++ mysql-test/suite/parts/t/truncate_locked.test | 10 + mysql-test/suite/plugins/r/processlist.result | 6 + mysql-test/suite/plugins/r/server_audit.result | 12 + mysql-test/suite/plugins/t/processlist.test | 20 + mysql-test/suite/plugins/t/server_audit.test | 7 + mysql-test/suite/rpl/r/rename.result | 34 + .../rpl/r/rpl_mixed_implicit_commit_binlog.result | 528 ++++----------- .../rpl/r/rpl_row_implicit_commit_binlog.result | 523 ++++----------- .../rpl/r/rpl_stm_implicit_commit_binlog.result | 515 ++++----------- mysql-test/suite/rpl/t/rename.test | 33 + mysql-test/suite/unit/suite.pm | 7 +- mysql-test/suite/vcol/r/vcol_misc.result | 10 + mysql-test/suite/vcol/t/vcol_misc.test | 18 + mysql-test/t/alter_table.test | 48 ++ mysql-test/t/assign_key_cache.test | 13 + ...cache-5405.test => assign_key_cache_debug.test} | 0 mysql-test/t/auto_increment.test | 25 + mysql-test/t/bootstrap.test | 9 + mysql-test/t/create_or_replace.test | 25 + mysql-test/t/ctype_binary.test | 3 + mysql-test/t/ctype_eucjpms.test | 2 + mysql-test/t/ctype_euckr.test | 11 + mysql-test/t/ctype_gbk.test | 3 + mysql-test/t/ctype_latin1.test | 3 + mysql-test/t/ctype_ucs.test | 4 + mysql-test/t/ctype_ujis.test | 4 + mysql-test/t/ctype_utf16.test | 5 + mysql-test/t/ctype_utf16le.test | 13 + mysql-test/t/ctype_utf32.test | 8 + mysql-test/t/ctype_utf8.test | 7 + mysql-test/t/ctype_utf8mb4.test | 8 + mysql-test/t/derived.test | 21 + mysql-test/t/grant.test | 11 +- mysql-test/t/grant2.test | 3 +- mysql-test/t/grant_not_windows.test | 13 + mysql-test/t/having.test | 17 + mysql-test/t/insert_select.test | 10 + mysql-test/t/join.test | 53 ++ mysql-test/t/join_cache.test | 32 +- mysql-test/t/join_outer.test | 48 ++ mysql-test/t/limit.test | 14 + mysql-test/t/lock.test | 2 +- mysql-test/t/myisam.test | 13 + mysql-test/t/mysql.test | 16 +- mysql-test/t/mysql_cp932.test | 42 +- mysql-test/t/mysqldump.test | 22 + mysql-test/t/mysqlslap.test | 8 + mysql-test/t/rename.test | 53 ++ mysql-test/t/selectivity.test | 18 + mysql-test/t/stat_tables.test | 50 ++ mysql-test/t/statistics.test | 24 + mysql-test/t/statistics_close.test | 18 + mysql-test/t/subselect.test | 15 + mysql-test/t/subselect4.test | 2 +- mysql-test/t/subselect_sj2_mat.test | 178 ++++++ mysql-test/t/subselect_sj_mat.test | 79 +++ mysql-test/t/union.test | 15 + mysql-test/unstable-tests | 161 +++-- mysql-test/valgrind.supp | 13 + mysys/my_rename.c | 5 +- plugin/server_audit/server_audit.c | 29 +- scripts/CMakeLists.txt | 2 + scripts/mysql_install_db.pl.in | 2 +- scripts/mysql_install_db.sh | 7 +- scripts/mysql_system_tables_fix.sql | 50 +- scripts/mysqld_multi.sh | 2 +- sql-common/client.c | 30 +- sql/ha_partition.cc | 3 +- sql/handler.h | 10 +- sql/item.cc | 11 +- sql/item.h | 5 + sql/item_strfunc.cc | 112 ++-- sql/log.cc | 10 +- sql/log_event.cc | 4 - sql/mysql_install_db.cc | 2 +- sql/mysql_upgrade_service.cc | 20 +- sql/mysqld.cc | 15 +- sql/opt_subselect.cc | 72 ++- sql/share/CMakeLists.txt | 12 +- sql/sql_acl.cc | 13 +- sql/sql_admin.cc | 19 +- sql/sql_base.cc | 61 +- sql/sql_base.h | 6 +- sql/sql_class.cc | 97 --- sql/sql_class.h | 2 - sql/sql_delete.cc | 2 +- sql/sql_handler.cc | 5 +- sql/sql_insert.cc | 3 +- sql/sql_parse.cc | 95 ++- sql/sql_parse.h | 1 + sql/sql_rename.cc | 2 +- sql/sql_select.cc | 90 +-- sql/sql_show.cc | 103 ++- sql/sql_statistics.cc | 48 +- sql/sql_statistics.h | 1 + sql/sql_table.cc | 71 ++- sql/sql_truncate.cc | 3 +- sql/table.cc | 32 +- sql/table_cache.cc | 2 + sql/tztime.cc | 2 +- storage/archive/ha_archive.cc | 2 +- storage/connect/filamvct.cpp | 5 - storage/connect/tabjson.cpp | 14 +- storage/csv/ha_tina.cc | 2 +- storage/federated/ha_federated.cc | 2 +- storage/federatedx/ha_federatedx.cc | 2 +- storage/heap/hp_hash.c | 2 +- storage/innobase/buf/buf0buddy.cc | 2 +- storage/innobase/buf/buf0dump.cc | 2 +- storage/innobase/dict/dict0dict.cc | 3 +- storage/innobase/fil/fil0fil.cc | 110 ---- storage/innobase/fts/fts0fts.cc | 76 +-- storage/innobase/fts/fts0opt.cc | 175 +---- storage/innobase/handler/ha_innodb.cc | 37 +- storage/innobase/handler/handler0alter.cc | 124 ++-- storage/innobase/handler/i_s.cc | 47 +- storage/innobase/include/fil0fil.h | 4 - storage/innobase/include/fts0fts.h | 8 +- storage/innobase/include/fts0priv.h | 18 +- storage/innobase/include/univ.i | 2 +- storage/innobase/os/os0file.cc | 31 +- storage/innobase/row/row0import.cc | 95 ++- storage/innobase/row/row0log.cc | 126 +--- storage/innobase/row/row0merge.cc | 3 +- storage/innobase/row/row0mysql.cc | 12 + storage/innobase/trx/trx0trx.cc | 4 +- storage/innobase/trx/trx0undo.cc | 3 +- storage/maria/ha_maria.cc | 141 ++-- storage/maria/ha_maria.h | 1 + storage/maria/ma_blockrec.c | 3 +- storage/maria/ma_close.c | 2 + storage/maria/ma_commit.c | 17 +- storage/maria/ma_extra.c | 4 +- storage/maria/ma_key.c | 2 +- storage/maria/ma_loghandler.c | 219 ++++++- storage/maria/ma_open.c | 4 +- storage/maria/ma_recovery.c | 11 + storage/maria/ma_state.c | 48 +- storage/maria/ma_state.h | 2 +- storage/maria/ma_trnman.h | 65 ++ storage/maria/maria_def.h | 14 +- storage/maria/trnman.c | 1 + storage/maria/trnman.h | 3 +- storage/myisam/ha_myisam.cc | 8 +- storage/myisam/mi_check.c | 6 +- storage/myisam/mi_key.c | 2 +- storage/myisam/mi_locking.c | 6 +- storage/tokudb/CMakeLists.txt | 6 + storage/tokudb/PerconaFT/ft/ft-ops.cc | 8 +- .../tokudb/PerconaFT/ft/serialize/ft-serialize.cc | 16 +- .../PerconaFT/ft/serialize/ft_node-serialize.cc | 116 ++-- storage/tokudb/PerconaFT/portability/memory.h | 2 +- .../tokudb/PerconaFT/portability/toku_debug_sync.h | 3 - .../tokudb/PerconaFT/portability/toku_pthread.h | 12 +- storage/tokudb/PerconaFT/src/CMakeLists.txt | 2 +- .../third_party/xz-4.999.9beta/autogen.sh | 0 .../third_party/xz-4.999.9beta/build-aux/compile | 0 .../xz-4.999.9beta/build-aux/config.guess | 0 .../xz-4.999.9beta/build-aux/config.rpath | 0 .../xz-4.999.9beta/build-aux/config.sub | 0 .../third_party/xz-4.999.9beta/build-aux/depcomp | 0 .../xz-4.999.9beta/build-aux/install-sh | 0 .../third_party/xz-4.999.9beta/build-aux/ltmain.sh | 0 .../third_party/xz-4.999.9beta/build-aux/missing | 0 .../xz-4.999.9beta/extra/7z2lzma/7z2lzma.bash | 0 .../xz-4.999.9beta/tests/test_compress.sh | 0 .../third_party/xz-4.999.9beta/tests/test_files.sh | 0 storage/tokudb/PerconaFT/util/dmt.cc | 4 +- storage/tokudb/PerconaFT/util/omt.h | 8 +- storage/tokudb/tokudb_thread.h | 49 -- storage/xtradb/buf/buf0buddy.cc | 2 +- storage/xtradb/buf/buf0dump.cc | 2 +- storage/xtradb/dict/dict0dict.cc | 3 +- storage/xtradb/fil/fil0fil.cc | 110 ---- storage/xtradb/fts/fts0fts.cc | 76 +-- storage/xtradb/fts/fts0opt.cc | 175 +---- storage/xtradb/handler/ha_innodb.cc | 40 +- storage/xtradb/handler/handler0alter.cc | 175 ++--- storage/xtradb/handler/i_s.cc | 47 +- storage/xtradb/include/fil0fil.h | 4 - storage/xtradb/include/fts0fts.h | 8 +- storage/xtradb/include/fts0priv.h | 18 +- storage/xtradb/os/os0file.cc | 70 +- storage/xtradb/row/row0import.cc | 84 ++- storage/xtradb/row/row0log.cc | 138 +--- storage/xtradb/row/row0merge.cc | 3 +- storage/xtradb/row/row0mysql.cc | 20 +- storage/xtradb/trx/trx0trx.cc | 4 +- storage/xtradb/trx/trx0undo.cc | 3 +- strings/ctype-bin.c | 8 +- strings/ctype-euc_kr.c | 4 +- strings/ctype-mb.c | 100 +-- strings/ctype-simple.c | 22 +- strings/ctype-ucs2.c | 78 +-- strings/ctype-ujis.c | 8 +- strings/ctype-utf8.c | 20 +- support-files/CMakeLists.txt | 4 +- unittest/sql/CMakeLists.txt | 1 - 306 files changed, 6741 insertions(+), 4034 deletions(-) diff --cc sql/sql_class.cc index 59746d466ea,3b293935048..385ced114c8 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@@ -721,277 -717,6 +721,180 @@@ 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; - } - +#ifdef WITH_WSREP +extern int wsrep_on(void *thd) +{ + return (int)(WSREP(((THD*)thd))); +} +extern "C" bool wsrep_thd_is_wsrep_on(THD *thd) +{ + return thd->variables.wsrep_on; +} + +extern "C" bool wsrep_consistency_check(void *thd) +{ + return ((THD*)thd)->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING; +} + +extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode) +{ + thd->wsrep_exec_mode= mode; +} +extern "C" void wsrep_thd_set_query_state( + THD *thd, enum wsrep_query_state state) +{ + thd->wsrep_query_state= state; +} +extern "C" void wsrep_thd_set_conflict_state( + THD *thd, enum wsrep_conflict_state state) +{ + if (WSREP(thd)) thd->wsrep_conflict_state= state; +} + + +extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd) +{ + return thd->wsrep_exec_mode; +} + +extern "C" const char *wsrep_thd_exec_mode_str(THD *thd) +{ + return + (!thd) ? "void" : + (thd->wsrep_exec_mode == LOCAL_STATE) ? "local" : + (thd->wsrep_exec_mode == REPL_RECV) ? "applier" : + (thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" : + (thd->wsrep_exec_mode == LOCAL_COMMIT) ? "local commit" : "void"; +} + +extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd) +{ + return thd->wsrep_query_state; +} + +extern "C" const char *wsrep_thd_query_state_str(THD *thd) +{ + return + (!thd) ? "void" : + (thd->wsrep_query_state == QUERY_IDLE) ? "idle" : + (thd->wsrep_query_state == QUERY_EXEC) ? "executing" : + (thd->wsrep_query_state == QUERY_COMMITTING) ? "committing" : + (thd->wsrep_query_state == QUERY_EXITING) ? "exiting" : + (thd->wsrep_query_state == QUERY_ROLLINGBACK) ? "rolling back" : "void"; +} + +extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd) +{ + return thd->wsrep_conflict_state; +} +extern "C" const char *wsrep_thd_conflict_state_str(THD *thd) +{ + return + (!thd) ? "void" : + (thd->wsrep_conflict_state == NO_CONFLICT) ? "no conflict" : + (thd->wsrep_conflict_state == MUST_ABORT) ? "must abort" : + (thd->wsrep_conflict_state == ABORTING) ? "aborting" : + (thd->wsrep_conflict_state == MUST_REPLAY) ? "must replay" : + (thd->wsrep_conflict_state == REPLAYING) ? "replaying" : + (thd->wsrep_conflict_state == RETRY_AUTOCOMMIT) ? "retrying" : + (thd->wsrep_conflict_state == CERT_FAILURE) ? "cert failure" : "void"; +} + +extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd) +{ + return &thd->wsrep_ws_handle; +} + +extern "C" void wsrep_thd_LOCK(THD *thd) +{ + mysql_mutex_lock(&thd->LOCK_wsrep_thd); +} +extern "C" void wsrep_thd_UNLOCK(THD *thd) +{ + mysql_mutex_unlock(&thd->LOCK_wsrep_thd); +} +extern "C" time_t wsrep_thd_query_start(THD *thd) +{ + return thd->query_start(); +} +extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd) +{ + return thd->wsrep_rand; +} +extern "C" my_thread_id wsrep_thd_thread_id(THD *thd) +{ + return thd->thread_id; +} +extern "C" wsrep_seqno_t wsrep_thd_trx_seqno(THD *thd) +{ + return (thd) ? thd->wsrep_trx_meta.gtid.seqno : WSREP_SEQNO_UNDEFINED; +} +extern "C" query_id_t wsrep_thd_query_id(THD *thd) +{ + return thd->query_id; +} +extern "C" char *wsrep_thd_query(THD *thd) +{ + return (thd) ? thd->query() : NULL; +} +extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd) +{ + return thd->wsrep_last_query_id; +} +extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id) +{ + thd->wsrep_last_query_id= id; +} +extern "C" void wsrep_thd_awake(THD *thd, my_bool signal) +{ + if (signal) + { + mysql_mutex_lock(&thd->LOCK_thd_data); + thd->awake(KILL_QUERY); + mysql_mutex_unlock(&thd->LOCK_thd_data); + } + else + { + mysql_mutex_lock(&LOCK_wsrep_replaying); + mysql_cond_broadcast(&COND_wsrep_replaying); + mysql_mutex_unlock(&LOCK_wsrep_replaying); + } +} +extern "C" int wsrep_thd_retry_counter(THD *thd) +{ + return(thd->wsrep_retry_counter); +} +extern "C" bool wsrep_thd_skip_append_keys(THD *thd) +{ + return thd->wsrep_skip_append_keys; +} + +extern int +wsrep_trx_order_before(void *thd1, void *thd2) +{ + if (wsrep_thd_trx_seqno((THD*)thd1) < wsrep_thd_trx_seqno((THD*)thd2)) { + WSREP_DEBUG("BF conflict, order: %lld %lld\n", + (long long)wsrep_thd_trx_seqno((THD*)thd1), + (long long)wsrep_thd_trx_seqno((THD*)thd2)); + return 1; + } + WSREP_DEBUG("waiting for BF, trx order: %lld %lld\n", + (long long)wsrep_thd_trx_seqno((THD*)thd1), + (long long)wsrep_thd_trx_seqno((THD*)thd2)); + return 0; +} +extern "C" int +wsrep_trx_is_aborting(void *thd_ptr) +{ + if (thd_ptr) { + if ((((THD *)thd_ptr)->wsrep_conflict_state == MUST_ABORT) || + (((THD *)thd_ptr)->wsrep_conflict_state == ABORTING)) { + return 1; + } + } + return 0; +} +#endif - #if MARIA_PLUGIN_INTERFACE_VERSION < 0x0200 /** TODO: This function is for API compatibility, remove it eventually. diff --cc sql/sql_parse.cc index 2b11e492a94,a9849c7248d..7e3590bcc83 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@@ -5839,8 -5337,62 +5838,61 @@@ static bool execute_show_status(THD *th } - static bool check_rename_table(THD *thd, TABLE_LIST *first_table, - 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 execute_rename_table(THD *thd, TABLE_LIST *first_table, + TABLE_LIST *all_tables) { DBUG_ASSERT(first_table == all_tables && first_table != 0); TABLE_LIST *table; @@@ -5854,7 -5406,12 +5906,12 @@@ &table->next_local->grant.privilege, &table->next_local->grant.m_internal, 0, 0)) - return 1; + return true; + + /* 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 @@@ -5867,10 -5425,10 +5925,17 @@@ INSERT_ACL | CREATE_ACL) && check_grant(thd, INSERT_ACL | CREATE_ACL, &new_list, FALSE, 1, FALSE))) - return 1; + return true; } - return false; ++ WSREP_TO_ISOLATION_BEGIN(0, 0, first_table) ++ + return mysql_rename_tables(thd, first_table, 0); ++ ++#ifdef WITH_WSREP ++error: ++ return true; ++#endif }